Search code examples
c++c++11casablancacpprest-sdk

400 Bad request with casablanca cpprestsdk


  http_request request(methods::POST);
    request.headers().add(L"Content-Type", L"application/json; charset=utf-8");
    request.headers().add(L"X-Requested-With", L"XMLHttpRequest");
    request.set_body(body);

The code above gives the following output:

HTTP/1.1 400 Bad Request
Connection: close
Content-Length: 334
Content-Type: text/html; charset=us-ascii
Date: Fri, 10 Mar 2017 23:05:43 GMT
Server: Microsoft-HTTPAPI/2.0

Can you tell me what's wrong with my parameters?


Solution

  • Found out that the client was trying to connect on localhost but using its hostname. When change the client's configuration to connect to localhost:8088 instead of degenerated:8088 it worked. So its a mismatch between the listening address and the target address.