I need to do an Http POST to my google form, and following an advice (http://productforums.google.com/forum/#!topic/docs/iCfNwOliYKY) I created a URL syntax like this:
https://docs.google.com/forms/d/MY_FORM_ID&entry.2087820476=hello&entry.261928712=dear&submit=Submit
Eventually I'll do the POST from iOS and Android, but I'm testing it simply in the browser and it doesn't work. I get back a Google Drive response that says "Sorry, the file you have requested does not exist." and the entry doesn't go into my responses spreadsheet.
What am I missing? I looked everywhere but nothing seem to answer this question.
EDIT:
I guess sometimes it's better to test directly on your target platform. The following code works for iOS:
NSString *post = @"&key1=val1&key2=val2";
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"https://docs.google.com/forms/d/MY_FORM_ID/formResponse"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSHTTPURLResponse* urlResponse = nil;
NSError *error = [[NSError alloc] init];
[NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];
Send a POST to following url
https://docs.google.com/forms/d/e/[FORM_ID]/formResponse?entry.1098499744=AnswerField1&entry.1090138332=AnswerField2
You can find your FORM_ID in the url when you preview your form.
To get the field ids, check the "name" attribute of each input tag. Or run the following script in the console on the form page.
Should print something similar to this in your console
Try to debug and check you final URL it should be something like this https://docs.google.com/forms/d/YOUR_FORM_ID/formResponse?entry.1748727384=test&entry.1949164265=test&submit=Submit
I did this task by using Swift. Check it out in this repo: https://github.com/goktugyil/QorumLogs
Here is the tutorial of how to set it up: https://github.com/goktugyil/QorumLogs/blob/master/Log%20To%20GoogleDocs.md
Heres the code to do it:
If you look at the form using Google Chrome developer tools, or the tools of any browser, you will see that each control has a name. Example:
name='entry.123456789'
In C# you can set the answers on a form like this:
You can also set the answers in the URL: