Poco::Net::HTTPClientSession json data Content-Type not received Poco::Net::HTTPClientSession json data Content-Type not received json json

Poco::Net::HTTPClientSession json data Content-Type not received


Got a little confused by the stateful stream style of communication. It is http and technically still a stateless connection. All of the information about the request, EXCEPT THE BODY, must be done before you send the initial request.

HTTPClientSession session(uri.getHost(), uri.getPort());HTTPRequest request(HTTPRequest::HTTP_POST, path, HTTPMessage::HTTP_1_1);HTTPResponse response;std::stringstream ss;obj.stringify(ss);request.setKeepAlive(true);request.setContentLength(ss.str().size());request.setContentType("application/json");  // definately set Content-Type right?std::ostream& o = session.sendRequest(request);obj.stringify(o);             // can confirm it is spitting out the valid std::cout << response.getStatus() << " " << response.getReason() << std::endl;

Also, needed to set the contentLength which I'd tried before but wasn't working due to the content-type not being sent properly. After the content length and type were set right, the server received correctly without a hitch.