api 2.0, oauth, and patch....
mattdm
Registered Users Posts: 16 Big grins
I'm trying to hack up the code from https://api.smugmug.com/api/v2/doc/tutorial/oauth/non-web.html to do some bulk manipulation on my photos. I used it to obtain a Full/Modify access token and secret, and then made a modified copy of the code which just uses that rather than requesting another one.
This works great for `get`. But I'm trying to use `patch` to modify the caption, and I get
{'Code': 401, 'Message': 'Unauthorized'}
Is there example code for this somewhere?
UPDATE: fixed! Problem was that Content-Type: application/json needs to be given explicitly for PATCH. See below for details.
This works great for `get`. But I'm trying to use `patch` to modify the caption, and I get
{'Code': 401, 'Message': 'Unauthorized'}
Is there example code for this somewhere?
UPDATE: fixed! Problem was that Content-Type: application/json needs to be given explicitly for PATCH. See below for details.
0
Comments
What am I doing wrong?
I discovered this by switching in desperation from rauth to oauthlib (https://github.com/idan/oauthlib), which is basically a drop-in replacement in this simple case, with a few terminology changes — but for some reason it gave me a helpful message, explaining that "application/x-www-form-urlencoded cannot be used when the HTTP method is PATCH.", which lead me to the answer. I don't know why I don't get this helpful error with rauth. In any case, I first made it work with oauthlib, and then went back to rauth, and — it works too!
Hello need some help :
I am trying to follow the above examples and want to update the privacy setting for few of the albums to unlisted
For some reason, I am getting the below error :
{"Code":400,"Message":"Invalid JSON: Syntax error"}
Looks like the issue with the data field - but i am not able to figure out.
Any help would be appreciated.
I have close to 100+ to be updated with the correct settings,
Thanks in advance.
Siva
Siva, you need to pass the data as a JSON string, your code is presenting an object.