Page 1 of 1

Submit to Google Spreadsheets works every *other* time???

Posted: Tue Jun 16, 2009 2:43 am
by acidjazz
A couple of months back SparkOut was kind enough to help me mimic what Google Forms does using "post ... to url" in Revolution. Seemed to work fine - the data shows up in Google Spreadsheets quite nicely. Except... Lately however, and almost without fail (there HAVE been a few exceptions, but very few) only every *other* post seems to work. I get "error bad request" on 1st, 3rd, 5th, or on the 2nd, 4th, 6th, depending on -- apparently the phase of the moon! It doesn't seem to matter how much time there is in between posts. Whether I submit fast (< 1 second between posts) or slow (couple of minutes between), it takes every other one. Just for fun, I went back to the original actual google form and submitted as fast as I possibly could (submit, backspace, submit, etc) and it took it every time! This is exactly the same form as I'm mimicking, so the http address is identical. So strange! Here's one variation on the code (I've tried a couple of different ways of encoding for url, and they all have the same result)...

Code: Select all

on mouseup
     local tFieldName1, tFieldName2, tFieldValue1, tFieldValue2, tDatatoPost
     put "entry.2.single" into tFieldName1 
     put "entry.3.single" into tFieldName2 
     put "SparkOut" into tFieldValue1 
     put 999 into tFieldValue2 
     put libUrlFormData (tFieldName1, tFieldValue1, tFieldName2, tFieldValue2) into tDataToPost 
     post tDatatoPost to URL ("http://spreadsheets.google.com/formResponse?formkey=clN1U2kxSDdOYWMtY2ltTTdna0xkUlE6MA..")
     answer it
end mouseup
I initially discovered this in a loop when I was posting 5 lines from a data set in rapid succession. I then turned off the loop and submitted (slowly) one line at a time. Yup, every *other* one! I've tried it multiple times over a period of 24 hours. Is there something that I've stupidly overlooked? I've tried different sorts and amounts of data in the post, and google will take anything I submit but only on every *other* post. Sometimes it's the first post. Sometimes the second. If it works on the first, it almost never works on the second, and vice versa. I created a new spreadsheet (i.e., used a different address to post to), and again, takes every other one!

Help!
Mark

EDIT------------
For what it's worth, this was the original code that I was using when the problem started. Different data, different number of vars, and different way of encoding for url (i.e, by hand), but the result is the same. Every other post works! :-(

Code: Select all

on mouseUp
     global gDATA
     
     repeat with Y = 1 to 5
          put empty into myDATA
          repeat with X = 1 to 5
               put "entry." & X & ".single=" & item X of line Y of gDATA & "&" after myDATA
          end repeat
          delete last char of myDATA
          post myDATA to URL ("http://spreadsheets.google.com/formResponse?formkey=clN1U2kxSDdOYWMtY2ltTTdna0xkUlE6MA.. ")
          answer it
     end repeat
end mouseUp

Posted: Tue Jun 16, 2009 1:21 pm
by SparkOut
Is it ok for me to bump up some duff data to that link to check out what's happening?
Do you have any cookie handling going on, btw?
Any HTTPheaders set?

Posted: Wed Jun 17, 2009 1:36 am
by acidjazz
Oh, absolutely. Submit whatever you like. All the data in there is completely fake. I've got no cookie handling -- well, I don't think so. I'm not doing anything with cookies in my rev code -- is that what you mean? As for the HttpHeader -- I wouldn't know what that was if it bit me on the nose! So, I probably don't have one of those either. :?

Thanks,
Mark

Posted: Wed Jun 17, 2009 10:35 am
by SparkOut
I've done a few submissions and everything seemed ok, there were no clues as to anything going wrong.
So I tried on a Google docs sheet of my own, with the script adjusted

Code: Select all

on mouseup 
   local tFieldName1, tFieldName2, tFieldValue1, tFieldValue2, tDatatoPost 
   libURLSetLogField the name of field "fldLog" -- put a logging field on my stack to be able to see the header responses in both directions
   put "entry.0.single" into tFieldName1 
   put "entry.1.single" into tFieldName2 
   put "SparkOut_" & any char of "ABCDEFGHIJKLMNOPQRSTUVWXYZ" into tFieldValue1 -- just to make a randomly different entry each time
   put the cVal of me into tFieldValue2 -- I initialised the custom property "cVal" of the button to 20001
   put libUrlFormData (tFieldName1, tFieldValue1, tFieldName2, tFieldValue2) into tDataToPost 
   post tDatatoPost to URL ("http://spreadsheets.google.com/formResponse?formkey=cEtwVFBxVHViaGNXUzVHT0VhaUE5TXc6MA..") 
   put it into field "fldResult" --just so that it stays out of the way while I repeatedly click
   add 1 to tFieldValue2 -- cycle up the value posted on each click
   set the cVal of me to tFieldValue2
end mouseup
Everything submitted to my form in good order, every click resulting in an entry on the sheet. So I changed the keycode to your form again and tried on your sheet. Did you get a bunch of results (about 20001 up to 20040) all in order?
Feel free to use my formkey to make your own submissions to the duff test form I made and I'll let you know if the submissions come in correct order.
If the entries I submitted to your form are there all in order, then I can only guess there may be some proxy on your gateway which is discarding entries for some reason. If not, and/or your submissions to my form come in OK, then I don't know.

Posted: Wed Jun 17, 2009 2:24 pm
by acidjazz
SparkOut,
That worked. I got 20001 to 20040 all good. They came in at about 2 submissions per second. I'll try the script tonight and see how things go. I appreciate your help.
Mark