Open alexhayes opened 2 years ago
This can be closed as INVALID - it would appear that for methods that are HTTP POST you need to provide a body
attribute with the values in it - as follows;
media_items = service.mediaItems().search(body=dict(albumId="xyz")).execute()
That seems somewhat unintuitive to me and I'm not able to find that documented - I just found it by chance as I was digging around StackOverflow (and yes, the issue template says "check SO", I did, but didn't find it initially).
As a consumer of an API, do I really care if it's a POST, GET, PATCH etc..? As an engineer I definitely want to know what happens under the hood, but it feels a bit off to be exposed to that by the interface signature. My assumption is there are good reasons.
If someone would like me to, I'm happy to document this via a PR if there is a particular area of the docs someone thinks is the best place to put it.
Hi @alexhayes,
I agree this information can be difficult to find. In case you're still interested in updating the docs, PRs are welcome !
This can be closed as INVALID - it would appear that for methods that are HTTP POST you need to provide a
body
attribute with the values in it - as follows;media_items = service.mediaItems().search(body=dict(albumId="xyz")).execute()
That seems somewhat unintuitive to me and I'm not able to find that documented - I just found it by chance as I was digging around StackOverflow (and yes, the issue template says "check SO", I did, but didn't find it initially).
As a consumer of an API, do I really care if it's a POST, GET, PATCH etc..? As an engineer I definitely want to know what happens under the hood, but it feels a bit off to be exposed to that by the interface signature. My assumption is there are good reasons.
If someone would like me to, I'm happy to document this via a PR if there is a particular area of the docs someone thinks is the best place to put it.
I spent hours testing and surfing the internet until I found your comment, thanks !
TL/DR This is not a bug - see my comment.
When attempting to call the search method from the
mediaItems
resource for Google Photos API with any of the allowed parameters an exception is thrown as follows;I suspect this has something to do with the discovery URL which, for the method in question, does not define any parameters.
As shown, it does define a
request
with a$ref
ofSearchMediaItemsRequest
, which in the discovery URL is as follows;As far as I can ascertain however google-api-python-client doesn't appear to reference
$ref
anywhere, so I am assuming it takes the method signature only fromparameters
defined in the discovery URL.Oddly enough however, when theResource
is created, there are some parameters set for thesearch
method, but these appear to be derived from somewhere else (perhapsoath2.v2.json
???) See below;EDIT: It would appear these are set by
_fix_up_parameters
in discovery.py which happens to all methods.Given it appears the parameters in the discovery URL are incorrect, I'm unsure if this is a bug in
google-api-python-client
- if not, please direct me to where I should raise this.NOTE: Calls without any parameters return the expected result (ie. media items).
Environment details
google-api-python-client
version: 2.44.0Steps to reproduce
serviceName='photoslibrary', version='v1'
service.mediaItems().search(albumId="xyz").execute()
Code example
Stack trace