new_http_batch_request throwing 501:"Operation is not implemented, or supported, or enabled." for sheets service
I am trying to get google worksheet information in a batch call but getting the following from the server response
<HttpError 501 when requesting https://sheets.googleapis.com/v4/spreadsheets/1NYpP_4haZR-EuhlbccoQOut8psmyvDJr0FLHsePTwAI?ranges=%27Sandeep+-Wedding+Contributions%27%21B2&fields=sheets%28data%28rowData%28values%28effectiveFormat%2FnumberFormat%2Ftype%2CeffectiveValue%29%29%29%29&includeGridData=true&alt=json returned "Operation is not implemented, or supported, or enabled.". Details: "Operation is not implemented, or supported, or enabled.">
Environment details
- OS type and version: MacOS ventura 13.2.1
- Python version: 3.10.13
- pip version: 23
google-api-python-clientversion: 2.78.0
Steps to reproduce
- A method which return googleapiclient http object, which on '.execute', makes the api call and returns the desired successfully
def get_sheet_data(sheet):
(service.spreadsheets()
.get(
spreadsheetId = sheet.sheet_id,
ranges = range_query,
'fields': 'sheets(data(rowData(values(effectiveFormat/numberFormat/type,effectiveValue))))',
'includeGridData': 'true', ))
- when I call the same above with batch, I get the mentioned above error
service = discovery.build(('sheets', 'v4'), http=http)
batch = service.new_http_batch_request()
for item in items:
batch.add(
get_sheet_data(item),
callback=another_method
)
batch.execute
- When executed, I get exception (amongst id, response and exception) the highlighted 501 response
Please note that this utility works fine with drive service, and also worked fine with google-api-python-client 1.6.2
Please let me know if you need more data, or this utility has been replaced by some other function
Tried below as well https://googleapis.github.io/google-api-python-client/docs/epy/googleapiclient.http.BatchHttpRequest-class.html
HttpError: <HttpError 404 when requesting https://www.googleapis.com/batch returned "Not Found". Details: "
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/logos/errorpage/error_logo-150x54-2x.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p> <ins>That’s all we know.</ins>
">
I get the exact same error using the slides service.
I do encounter same issue while using .Net client. @atulep you flag this as a bug, but shouldn't it be on Google side that something is wrong ?
Hi @oromand. If you're experiencing the same issue with the .Net client, then it seems like a back-end issue, not a client library issue. (You can verify this by trying to call this method from the widget on https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get).
Escalating to the service team.
Hi @oromand. If you're experiencing the same issue with the .Net client, then it seems like a back-end issue, not a client library issue. (You can verify this by trying to call this method from the widget on https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get).
Escalating to the service team.
I contacted the service team, and it turns out that the platform feature that processes HTTP batch requests was disabled for Google Workspace editors in 2022. However, you can still batch-process various types of documents at the API level using API-specific methods such as documents.batchUpdate.
Here's the announcement for the Google Sheets API, and the various batch methods you can use: https://developers.google.com/sheets/api/guides/batch-deprecation.
Hope this helps!
Thanks for your return. I have had the same feedback from the support team. It will hopefully help others in the future.