2

Hello I'm using the WinHttpClient.h and I want to send some POST data in a body to the server, at the moment it only sends the parameters (REST) of the POST request, can you please tell me what can be the problem that the POST body is empty? Thank you in advance.

::WinHttpSendRequest(hRequest,
m_additionalRequestHeaders.c_str(), - wstring
m_additionalRequestHeaders.length(),
m_pDataToSend,- BYTE *
m_dataToSendSize,
m_dataToSendSize + m_additionalRequestHeaders.length(),
NULL);

The function is set to work synchronously.

::WinHttpOpen(m_userAgent.c_str(),  
  WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
  WINHTTP_NO_PROXY_NAME, 
  WINHTTP_NO_PROXY_BYPASS,
  0);

enter image description here

As you can see the post body is empty. The data is just for testing. No password or username has been compromised

Mr. Hello_world
  • 85
  • 2
  • 10
  • if your message has content in body, most probably, you forgot to add Content-Length and Content-Type headers, in this case body probably will be send but the server will not accept – vitalygolub Oct 19 '17 at 13:27
  • I checked that: m_additionalRequestHeaders.c_str() = "\r\nContent-Type: application/x-www-form-urlencoded\r\n" and content length has this string length – Mr. Hello_world Oct 19 '17 at 13:31
  • what is the type of `m_additionalRequestHeaders`? – David Haim Oct 19 '17 at 13:44
  • @DavidHaim its wstring and m_pDataToSend is a BYTE *. I also tried to use the example from the WinHttpClient.h site and it does not send the body. – Mr. Hello_world Oct 19 '17 at 14:41

0 Answers0