Recently I was trying to make a HTTP POST query in Windows Mobile but the POST query was not successful. This is what I have been trying to do

Here sRequestHeaders is the headers which is in Unicode and the MSDN documentation says the following about “lpOptional” parameter which is used for POST parameters

pOptional [in]

Pointer to a buffer containing any optional data to be sent immediately after the request headers. This parameter is generally used for POST and PUT operations. The optional data can be the resource or information being posted to the server. This parameter can be NULL if there is no optional data to send.

dwOptionalLength [in]

Size of the optional data, in bytes. This parameter can be zero if there is no optional data to send.

It just says, pOptional is a buffer containing optional data and dwOptionalLength specifies the buffer in bytes, but when tried to send an Unicode buffer and its size in bytes to this call, the response was not 200 (HTTP_OK). After several attempts I found that the parameters had to be in ANSI buffer. All other parameters deal with LPCTSTR i.e TCHAR buffer, this one alone needs to be an ANSI buffer. Here is the code for that

if( FALSE == HttpSendRequest(hRequest, (LPCTSTR)sRequestHeaders, sRequestHeaders.GetLength(), LPVOID)(LPSTR)pszAnsiRequestParams, dwRequestParamsLen ) )

In the above call pszAnsiRequestParams is ANSI buffer and dwRequestParamsLen is the size of that buffer in bytes. Once I changed this, the response was 200. Is this how one will send the parameters always? If this is the case, how will I send Unicode POST parameters? Since in my case, I was dealing with ASCII characters for time being this is working fine but somehow I feel there should be a way out.

Can somebody post a solution what else am I missing here?