2
votes

I am trying to do HTTP post to a google form, from a C program in my device. For a legacy form, the active form submission URL looks like below. I used these text to do a URL encoded HTTP/1.1 POST, which was successful.

https://spreadsheets.google.com/formResponse?formkey=FORMKEY&ifq&entry.0.single=ENTRY1&entry.2.single=ENTRY2&submit=Submit

For the new google form (whichever you create from google drive now), below is the active submit URL. When I use this for HTTP post, I get the Bad Request with error Code 400.

https://docs.google.com/forms/d/FORMKEY/formResponse?entry.1252261890=ENTRY1&entry.1890412746=ENTRY2

What has changed between old and new google form? I see similar problem faced by somebody elsewhere but no solution so far. Thanks for your help.

1

1 Answers

0
votes

This is a javascript (google apps script) POST that is working on a current form (with one field!) Pperhaps you can get what you need from this:

function sendHttpPost() {

var fish = "I am a mackerel";

   var payload =
   {
     "entry.2071121932" : fish

   };

   // Because payload is a JavaScript object, it will be interpreted as
   // an HTML form. (We do not need to specify contentType; it will
   // automatically default to either 'application/x-www-form-urlencoded'
   // or 'multipart/form-data')

   var options =
   {
     "method" : "POST",
     "payload" : payload,
      "muteHttpExceptions": true
   };

 var response =  UrlFetchApp.fetch("https://docs.google.com/forms/d/this is the form ... key/formResponse", options);

Logger.log(response.getContentText())
 }