java - Posting data to new Google Forms -
with previous(legacy) version of google forms possible programatically post data form sending httppost url this:
https://spreadsheets.google.com/formresponse?formkey=[key]
and data this:
entry.1.single=data&entry.2.single=moredata
with new version of google forms (released jan 2013 think) url structure different. here snippet "view live form page"
<form action="https://docs.google.com/forms/d/1ee330gpkmhx_0dkwmjb6zpdm4fbhhqjsqbbgysetq6m/formresponse" method="post" ... <input type="text" name="entry.1566150510"
from code snippet think post url this:
https://docs.google.com/forms/d/[key]/formresponse
with data this:
entry.1566150510=data
but i've tried java(android) this:
public void postdata() { // create new httpclient , post header httpclient httpclient = new defaulthttpclient(); log.i(mytag, "inside postdata()"); string fullurl = "https://docs.google.com/forms/d/1ee330gpkmhx_0dkwmjb6zpdm4fbhhqjsqbbgysetq6m/formresponse"; log.i(mytag, "url = " + fullurl); httppost httppost = new httppost(urlbase); try { // add data list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2); namevaluepairs.add(new basicnamevaluepair("entry.1566150510", "somedata")); urlencodedformentity data = new urlencodedformentity(namevaluepairs); log.i(mytag, data.tostring()); httppost.setentity(data); log.i(mytag, entityutils.tostring(data)); // execute http post request responsehandler<string> responsehandler=new basicresponsehandler(); string response = httpclient.execute(httppost, responsehandler); log.i("docsuploader", "response = " + response); } catch (clientprotocolexception e) { // todo auto-generated catch block e.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } }
and 404, not found response.
am missing obvious here, or has google removed ability post new forms?
consider doing update google-apps-script (i suspect less work). , continue work if google make more tweaks.
Comments
Post a Comment