rust ByBit API v5返回错误代码170130:“为参数'%s'发送的数据无效,”没有说明参数'%s'是什么

izkcnapc  于 2023-02-23  发布在  其他
关注(0)|答案(1)|浏览(129)

我正尝试使用统一帐户发送现货订单。绝对没有关于此错误消息的含义的信息,就我从ByBit v5 API文档中所知,我做的一切都是正确的。我已经确定签名格式正确。这是发送沿着请求:

RequestBuilder {
method: POST,
url: Url {
    scheme: "https",
    cannot_be_a_base: false,
    username: "",
    password: None,
    host: Some(
        Domain(
            "api.bybit.com",
        ),
    ),
    port: None,
    path: "/v5/order/create",
    query: None,
    fragment: None,
},
headers: {
    "content-type": "application/json",
    "x-bapi-api-key": xxxxxxxxxxxxxx,
    "x-bapi-timestamp": "1676755850417",
    "x-bapi-sign": xxxxxxxxxxxxxxxx,
    "x-bapi-recv-window": "5000",
},}

发送请求时附加的请求正文:

{"category":"spot","symbol":"ETHUSDT","side":"Sell","order_type":"Market","qty":"0.1"}

这是用于发送请求的Rust代码:

// Set up the HTTP client
    let client = reqwest::Client::new();
    let mut headers = HeaderMap::new();
    headers.insert("Content-Type", HeaderValue::from_static("application/json"));
    headers.insert("X-BAPI-API-KEY", HeaderValue::from_str(&api_key)?);
    headers.insert("X-BAPI-TIMESTAMP", HeaderValue::from_str(&timestamp)?);
    headers.insert("X-BAPI-SIGN", HeaderValue::from_str(&sign)?);
    headers.insert("X-BAPI-RECV-WINDOW", HeaderValue::from_static(recv_window));

    let body = serde_json::to_string(&order)?;

        // Submit the order
        let request = client
            .post("https://api.bybit.com/v5/order/create")
            .headers(headers.clone())
            .body(body.clone());

        let response = request.send().await?;

以下是收到的答复:

Response {
url: Url {
    scheme: "https",
    cannot_be_a_base: false,
    username: "",
    password: None,
    host: Some(
        Domain(
            "api.bybit.com",
        ),
    ),
    port: None,
    path: "/v5/order/create",
    query: None,
    fragment: None,
},
status: 200,
headers: {
    "content-type": "application/json; charset=utf-8",
    "content-length": "122",
    "x-bapi-limit": "20",
    "x-bapi-limit-status": "19",
    "x-bapi-limit-reset-timestamp": "1676755851552",
    "ret_code": "170130",
    "traceid": "78d2bec29fead6e40447a63ba1eae5d9",
    "timenow": "1676755851556",
    "server": "Openresty",
    "expires": "Sat, 18 Feb 2023 21:30:51 GMT",
    "cache-control": "max-age=0, no-cache, no-store",
    "pragma": "no-cache",
    "date": "Sat, 18 Feb 2023 21:30:51 GMT",
    "connection": "keep-alive",
},}
wvt8vs2t

wvt8vs2t1#

必须确保在签名字符串和请求正文中是“orderType”而不是“order_type”。

相关问题