Closed jepessen closed 2 years ago
Http 400 usually mean that there is something wrong with the request data. What does their api documentation say about this error code?
The API does not say anything, specific, but the reply should contain in the body a message with more specific details. Is there a way to retrieve the body from a reply when the response code is 400?
Yes, you can turn off the throwing of exceptions on HTTP errors. That let you process error responses just like other responses.
For an example, see here: https://github.com/jgaa/restc-cpp/blob/b9c2aef049dbdb3de86db68ed15bd797bd8269fc/tests/functional/PropertiesTests.cpp#L26
Ok thanks. Removing the exception I can see the error message in the body, saying that the "User-Agent" header was missing. Adding it solved the problem. Thanks.
I'm trying to use the library in order to get data from coinbase API (https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproducts-1).
I'm on Windows 11.
This is my code sample:
The code compiles fine, but when I run it I catch the exception and the output is
If I use
https://lastviking.eu/files/api
instead ofhttps://api.exchange.coinbase.com/products
, everything it's fine and I obtain the correct response code:I can't understand what I'm doing wrong. According to Coinbase documentation, I'm doing the right thing. Just copy and paste the address into a browser returns the expected json to me.
I've tried to change the
boost::asio::ssl::context
options but with no luck.Someone knows what I'm doing wrong?