I
Ilho Ye
Guest
Hi,
I am trying to POST data on the webserver and I have a python script that will take name and data to create a file.
I have found a few examples of GET method but I could not quite find any complete example for POST method and I am getting an error when I call WinHttpSendRequest().
Here is part of my code that calls WinHttpSendRequest().
LPSTR data = "Content-Type: application/x-www-form-urlencoded
\nContent-Length: 29\r\nlocation=abcd.txt&data=\"cool\"\r\n";
DWORD data_len = strlen(data);
hRequest = WinHttpOpenRequest(hConnect, L"POST", L"/sd.py/save_data",
NULL, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES, 0);
if (!hRequest) {
wprintf(L"WinHttpOpenRequest failed (%d)\n", GetLastError());
goto out;
}
if (WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0,
(LPVOID)data, data_len, data_len, 0) != TRUE) {
wprintf(L"WinHttpSendRequest failed (%d)\n", GetLastError());
goto out;
}
I am getting 12002 error code right now and if anyone can show me how
I should create data string, I would really appreciate it. Thank you
in advance.
Continue reading...
I am trying to POST data on the webserver and I have a python script that will take name and data to create a file.
I have found a few examples of GET method but I could not quite find any complete example for POST method and I am getting an error when I call WinHttpSendRequest().
Here is part of my code that calls WinHttpSendRequest().
LPSTR data = "Content-Type: application/x-www-form-urlencoded
\nContent-Length: 29\r\nlocation=abcd.txt&data=\"cool\"\r\n";
DWORD data_len = strlen(data);
hRequest = WinHttpOpenRequest(hConnect, L"POST", L"/sd.py/save_data",
NULL, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES, 0);
if (!hRequest) {
wprintf(L"WinHttpOpenRequest failed (%d)\n", GetLastError());
goto out;
}
if (WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0,
(LPVOID)data, data_len, data_len, 0) != TRUE) {
wprintf(L"WinHttpSendRequest failed (%d)\n", GetLastError());
goto out;
}
I am getting 12002 error code right now and if anyone can show me how
I should create data string, I would really appreciate it. Thank you
in advance.
Continue reading...