HTTP post

Showing results for 
Search instead for 
Did you mean: 

HTTP post

Contributor III

Hi i am trying to POST data to Google spreadsheet like andrino, but i am not able succeed. i have return the code for POST.

strcat (cServer_WriteBuff,"entry.1446189103=");
strcat (cServer_WriteBuff,POST);
strcat (cServer_WriteBuff,"&submit=Submit");
value = strlen(cServer_WriteBuff);
error = send(sock, "POST /formResponse?formkey=", sizeof("POST /formResponse?formkey="), 0);
error = send(sock, (void *)formkey, sizeof(formkey), 0);
error = send(sock, "&ifq HTTP/1.1\r\n", sizeof("&ifq HTTP/1.1\r\n"), 0);
error = send(sock, "Host:\r\n", sizeof("Host:\r\n"), 0);
error = send(sock, "Content-Type: application/x-www-form-urlencoded\r\n", sizeof("Content-Type: application/x-www-form-urlencoded\r\n"), 0);
error = send(sock, "Connection: close\r\n", sizeof("Connection: close\r\n"), 0);
error = send(sock, (void *)value, sizeof(value), 0);
error = send(sock, "\r\n", sizeof("\r\n"), 0);
error = send(sock, "\r\n", sizeof("\r\n"), 0);
error = send(sock, (void *)cServer_WriteBuff, sizeof(cServer_WriteBuff), 0);
error = send(sock, "\r\n", sizeof("\r\n"), 0);
error = send(sock, "\r\n", sizeof("\r\n"), 0);

  but when i check it on Hercules terminal, it only shows " POST /formResponse?formkey=" can anyone please help to figure out, or any suggestion. i am tring to use httpsrv code but being a beginner not able to figure how to use it.

Labels (1)
Tags (1)
0 Kudos
1 Reply

Contributor IV


please try to use function strlen instead of sizeof in calls of send() function. Using sizeof in this context means that you also send terminating null character ('\0') in your messages, which is probably why you cannot receive any other than first message. Also on line 16 you are calling sizeof(formkey). I assume, that variable formkey is pointer so sizeof will return 4, which is probably not what you want. If you want to get length of string formkey is pointing to you should use strlen(formkey).

Best regards


0 Kudos