简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM