lundi 2 avril 2018

RESTful API, C++restSDK, JSON in C++

I am trying to use THIS RESTful API: https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md

To do this, I am using THIS C++ SDK: https://github.com/Microsoft/cpprestsdk

The Binance API returns everything as JSON, which is where I think my issue lies.

My code is here: https://pastebin.com/SeBAxvA0

Basically, I am trying to just test out this API by doing a simple GET method for the server time from the Binance API. According to the Binance documentation:

Check server time
GET /api/v1/time
Test connectivity to the Rest API and get the current server time.

Weight: 1

Parameters: NONE

Response:
{
  "serverTime": 1499827319559
}

So I would like to do a GET request for that JSON, and then have my C++ program output the value of serverTime. When I try to run my code as is, I get an error saying:

error: no viable overloaded operator[] for type
  'const json::value'
    auto response = value[L"responseData"];

However, I am following along with an example from the C++restSDK found here: http://mariusbancila.ro/blog/2013/08/02/cpp-rest-sdk-in-visual-studio-2013/

I think my issue has something to do with the two lines under the comment I made on line 45 in my pastebin. Presumably, I am assigning the wrong values to one or both of the variables under that line. I know this is a pretty specific help request, but does anyone know what I'm doing wrong and how to get the value of serverTime to display?

Aucun commentaire:

Enregistrer un commentaire