Проблема с post запросом Poloniex API “Invalid command” c++ libcurl

Всем доброго времени дня! Пытаюсь взаимодействовать с Poloniex API, но уже второй день ловлю одну и ту же ошибку

{"error":"Invalid command."}

Мой код:

int main() {
    CURL *curl_handle = curl_easy_init();
    if(curl_handle) {
        /* Формирование  запроса  */
        string post_data="";
        struct curl_slist *headers=NULL;
        string command = "command=returnBalances&nonce=" + to_string(time(0));
        cout<<command<<endl;
        string Secret = "МойСекрет";
        string Sign = "Sign: "+ hmac::get_hmac(Secret, command, hmac::TypeHash::SHA512);
        cout<<Sign<<endl;
        post_data += command;
        headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
        headers = curl_slist_append(headers, "Key: МойКлюч");
        headers = curl_slist_append(headers, Sign.c_str());
 
        curl_easy_setopt(curl_handle, CURLOPT_URL, "https://poloniex.com/tradingApi");
 
        curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDSIZE, post_data.length()+1);
        curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, post_data.c_str());
        curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, false);
        curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
 
    }
    curl_easy_perform(curl_handle);
    curl_easy_cleanup(curl_handle);
 
    return 0;
}

Отчет в консоли:

*   Trying 104.18.217.39:443...
* TCP_NODELAY set
* Connected to poloniex.com (104.18.217.39) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: businessCategory=Private Organization; jurisdictionC=US; jurisdictionST=Delaware; serialNumber=5959580; C=US; ST=Massachusetts; L=Boston; O=Poloniex, LLC; CN=poloniex.com
*  start date: May  6 00:00:00 2019 GMT
*  expire date: Jul 26 12:00:00 2021 GMT
*  subjectAltName: host "poloniex.com" matched cert's "poloniex.com"
*  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 Extended Validation Server CA
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55a7e8f15d10)
> POST /tradingApi HTTP/2
Host: poloniex.com
accept: */*
content-type: application/x-www-form-urlencoded
key: МойКлюч
sign: МойШмяк
content-length: 40

* We are completely uploaded and fine
* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 200 
< date: Thu, 25 Jun 2020 09:28:41 GMT
< content-type: application/json
< cf-rate-limit-rule-id: b25469efe9fb4045a37fe9427e8ae460
< cf-rate-limit-action: simulate
< retry-after: 1036
< set-cookie: __cfduid=d98b04dd8948c335b1aff6be61e208c821593077321; expires=Sat, 25-Jul-20 09:28:41 GMT; path=/; domain=.poloniex.com; HttpOnly; SameSite=Lax; Secure
< cache-control: private
< cf-cache-status: DYNAMIC
< cf-request-id: 038c67e66c0000d6dd580ff200000001
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< server: cloudflare
< cf-ray: 5a8da8ea4bd5d6dd-FRA
< 
* Connection #0 to host poloniex.com left intact

Результат функции get_hmac() проверял через онлайн сервисы, ошибок нет. Накидайте, пожалуйста, идей, в чем может быть проблема, я уже в тупике, перепробовал на свой взгляд всё...


Ответы (0 шт):