Reputation: 11
I am trying to get a JSON body for a sheet using Chrome for now, but to be incorporated in a python script.
The sheet contains 56 rows and 6 columns, but I get the error:
{
"error": {
"code": 400,
"message": "Range ('tab_name'!TAB_NAME) exceeds grid limits. Max rows: 994, max columns: 26",
"status": "INVALID_ARGUMENT"
}
}
I was thinking it did not like the alt=json anymore, but I get the same error with just the key on the end.
Upvotes: 0
Views: 2580
Reputation: 15187
You mention accessing the API as:
https://sheets.googleapis.com/v4/spreadsheets/[spreadsheet_id]/values/[tab_name]?alt=json&key=[api_key]
I've been through the same issue recently, and if you're receiving an error like:
exceeds grid limits. Max rows: XXX, max columns: YYY
Then the problem might be with the way you're representing [tab_name]
.
A similar issue was reported in the pygsheets library. The fix was to quote the tab name with single quotes, as in:
https://sheets.googleapis.com/v4/spreadsheets/[spreadsheet_id]/values/'[tab_name]'?alt=json&key=[api_key]
The reason for that is that sometimes the tab name can be interpreted as a range. Something like APP1
could be seen by gsheets as trying to refer to the column APP
, row 1
, rather than the tab named APP1
.
Adding single quotes around the tab name makes sure the google API interprets it as a tab name, rather than a cell address or range.
Upvotes: 0
Reputation: 1728
I assume you are trying to get values from a Sheet, as per the documentation the proper way to use this endpoint is GET https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}
you defined [tab_name] as part of the URL which is equal to SheetName
or sheetName!A:Z
, in other words, the error states that your request exceeds grid limits so you have to define a smaller grid, e.g. GET https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/Sheet1!A1:C5
.
As a suggestion I encourage you to take a look at the examples in the documentation.
Upvotes: 0