Google-sheets – Google Sheets Labels are returned as empty strings by SQL. Why

google sheets

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?

Best Answer

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.