I have a Google sheet for testing on which I want to run a query via a http: request using JQuery $.ajax. Works fine until I paste some additional rows. Still works then but when I remove any of the rows above the pasted ones the query returns "" for labels instead of the first row of the sheet. This means SQL is not recognising the first row as a header row which means sort by includes the first row. I have other sheets where everything works fine. It just seems pasting fouls things up. The reason for testing like that is that if I do a straightforward paste of say a list into an empty sheet and do the query, labels are always returned as "". Any data entered manually gives the expected result of labels=first row. Any ideas?


After a lot of hunting around as the Google docs is far from complete it looks as though the first row of a sheet can be forced to be a header and its cells used as labels by appending &headers=1 or indeed &headers= x if there are several header rows to the https query string.

I haven't tested this exhaustively but it seems to deal with a couple of bad use cases OK. What I haven't figured yet is why things worked OK in other sheets without &headers.

  • Without a parameter to specify headers, the query guesses at how many header rows (0,1,2...) there are, based on the content. Sometimes it guesses incorrectly, and it's hard to say why. – user135384 Jan 16 '17 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.