On Tuesday, 12 November 2002 at 02:17:39 UTC+5, Stephen Sulzer [Microsoft] wrote:
Hello Gigino,
I think the problem is the WinHttpSendRequest call:
// Send a request.
if (hRequest)
bResults =WinHttpSendRequest(hRequest,
WINHTTP_NO_ADDITIONAL_HEADERS , 0,
"CS=friuli", 18, 18,
0);
This code is posting a 9 byte string, but specifies that the length is 18 bytes. It should use 9 instead, as the payload is a 9-byte ANSI string, not
a wide-character Unicode string. Sending the string as single-byte ANSI is the correct thing to do. The dwOptionalLength and dwTotalLength parameters must specify the length of the data in bytes.
WinHTTP will use the dwTotalLength parameter to generate the Content-Length header. So the server is expecting 18 bytes of data, and this would cause
the timeout error.
Also, when calling the WinHttpAddRequestHeaders function, you do not need
the \r\n characters at the end of the string, so the following is
sufficient:
bResults=WinHttpAddRequestHeaders(hRequest,
L"Content-Type: application/x-www-form-urlencoded",
-1L, WINHTTP_ADDREQ_FLAG_ADD);
Hope that helps.
Regards,
Stephen Sulzer
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights. "Gigino" <[email protected]> wrote in message news:[email protected]...
"Stephen Sulzer \(Microsoft\)" <[email protected]> wrote in
message news:<OQtF2hrhCHA.1392@tkmsftngp12>...
Hello,
Are you using the WinHTTP Win32 API or the WinHttpRequest COM component?
Can you post an example of your code please?
Regards,
Stephen Sulzer
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no
rights.
"gigino" <[email protected]> wrote in message news:5ffb01c28448$7cebb8d0$36ef2ecf@tkmsftngxa12...
can someone please show me a sample code of a post request
in c++ with winhttp? I've followed all instructions but i
wasn't able to make it work...
I'm using the Winhttp win32 API; the segment of code i wrote to post
data to a server is the following; i followed an example of winhttp
help in which there was only the download of an html page and i've
made the changes i thought i needed to post data, but it doesn't
work...
"CS=friuli" is the string i want to post, the page is www.myservarname.it/rs/find.asp; the error i get is 12002 (timeout),
but the problem seems to be the post... if i only read the page
without posting data, there is no problem.
Thank you for any help
Gigino
Hi Stephen,
i am having an issue with the POST API my API seems to work ok as when i send data from postman it works absolutely fine but when i send the data from c++ it doesn't post any thing as there is a key whose value is quite long
here is my code below if you can help me
wstrURL+=L"Id=";
wstrURL += _id;//after this concatinate id provided
wstrURL+=L"&Email=";
wstrURL+=Email;//add email here
wstrURL+=L"&Public_Key=";
wstrURL+=_publicKey;//add public key
wstrURL += L"&Private_Key=";
wstrURL +=_privateKey; //add private key
//wstrURL += L"Content-Type: application/x-www-form-urlencoded\r\n";
WinHttpClient* pHttpClient = NULL;
pHttpClient = new WinHttpClient(wstrURL);
if (pHttpClient == NULL)
{
return;
}
LPCWSTR additionalHeaders = L"Content-Type: application/x-www-form-urlencoded\r\n";
//pHttpClient->SetAdditionalRequestHeaders(additionalHeaders);
pHttpClient->SendHttpRequest(L"POST",additionalHeaders);
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)