Admin SDK Reports API channels.stop() 404 because of wrong API URL
See original GitHub issueProblem
service = discovery.build('admin', 'reports_v1', http=http_obj)
resp = service.channels().stop(body={}).execute()
Raises a googleapiclient.errors.HttpError: <HttpError 404 when requesting https://www.googleapis.com/admin/reports/v1/admin/reports_v1/channels/stop? returned "Not Found">
Problem notes
I think the problem here is that this endpoint has a different URL format to the standard endpoint URL format, the correct URL for this endpoint is https://www.googleapis.com/admin/reports_v1/channels/stop
, it has a underscore instead of a slash to separate the version.
It seems that the discovery API is aware of this because in https://www.googleapis.com/discovery/v1/apis/admin/reports_v1/rest
all methods’ paths do not start with a slash, except for the channels.stop()
's path that starts with a slash (/admin/reports_v1/channels/stop
). Therefore I think this slash indicates that the whole URI should be replaced by the path, instead of appending the path to the base URL.
Possible solution
Having a look at the code I think this could be handled in googleapiclient.discovery._urljoin(). If the path starts with a slash replace the URI of the base URL with the path, instead of appending the path.
Notes
- Having said that, I don’t know if the rule “If the discovery API says that a method’s path starts with a slash then this path must replace the URI of the base URL” is true for all APIs.
- Seems like the URL in the documentation is also wrong, but I guess this is not the correct place to report that.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
If anyone has the same problem. A quick and dirty workaround is:
Hi @pacohh,
I ran the code below but I wan’t able to re-produce the 404 error. It’s likely that the issue is fixed. If you’re still having trouble please re-open this issue with additional information.