Uploading with API v2 (especially with rauth in Python)
drueter
Registered Users Posts: 4 Beginner grinner
I am successfully using SmugMug API v2 from a Python 3 application that I wrote that uses the rauth library for OAuth.
However, I am having problems uploading images.
At present, the response I am getting is:
stat: fail
method: smugmug.images.upload
code: 22
message: missing required parameter
When I perform the post, the body contains only the binary data for the image. The headers include:
Authorization: OAuth,
oauth_timestamp="1446202904",
oauth_signature="6ttkcYBWcAGADxNAy0MCAVbpH/w=",
oauth_signature_method="HMAC-SHA1",
oauth_consumer_key="H4xxxxxbZufAE4mVin7cKV1xxxheBy5A",
oauth_version="1.0",
oauth_nonce="d2a85670b53251f08be77a3d2c008daac18cb258",
oauth_token="8b3402xxx9ad5ecee6a0c0xxxfxx6d"
Accept: application/json
Accept-Encoding: gsip, deflate
Connection: keep-alive
Content-Length: 14535
Content-MD5: ZOJlDn/kI63WLVdcDNfAag==
Content-Type: image/jpeg
Cookie: xxxxx
User-Agent: python-reqeusts/2.8.1
X-Smug-AlbumUri: /api/v2/album/xxxx
X-Smug-Filename: test.jpg
X-Smug-ResponseType: JSON
X-Smug-Version: v2
I have reviewed the documentation at https://api.smugmug.com/api/v2/doc/reference/upload.html and have experimented by passing in static values for ALL of the parameters defined there--and still receive the same message.
How can I diagnose what parameter SmugMug thinks is missing?
FYI, I am definitely in an authenticated OAuth session on my GETs, and can retrieve private objects (private albums and the like). I had been having big problems with POST and binary data, and spend a lot of time working on this. It turns out that rauth is broken, in that it a) throws an error when you post binary data, and b) it does not seem to know how to put the OAuth params into the Authorization header.
Before I was getting responses like:
stat: fail
method: smugmug.images.upload
code 5
message: system error
and
stat: fail
method: smugmug.images.upload
code: 1
message: We're sorry, but you don't appear to be logged in to that account. Please login and try again.
Now that I have found (and I think fixed) some errors in the rauth library I no longer see these errors...so I think I am making progress. Once I have this all working, I can post some details of the fixes here, as well as submit them to the rauth team.
But I don't know what missing parameter SmugMug is complaining about.
Can you give me any suggestions or assistance?
However, I am having problems uploading images.
At present, the response I am getting is:
stat: fail
method: smugmug.images.upload
code: 22
message: missing required parameter
When I perform the post, the body contains only the binary data for the image. The headers include:
Authorization: OAuth,
oauth_timestamp="1446202904",
oauth_signature="6ttkcYBWcAGADxNAy0MCAVbpH/w=",
oauth_signature_method="HMAC-SHA1",
oauth_consumer_key="H4xxxxxbZufAE4mVin7cKV1xxxheBy5A",
oauth_version="1.0",
oauth_nonce="d2a85670b53251f08be77a3d2c008daac18cb258",
oauth_token="8b3402xxx9ad5ecee6a0c0xxxfxx6d"
Accept: application/json
Accept-Encoding: gsip, deflate
Connection: keep-alive
Content-Length: 14535
Content-MD5: ZOJlDn/kI63WLVdcDNfAag==
Content-Type: image/jpeg
Cookie: xxxxx
User-Agent: python-reqeusts/2.8.1
X-Smug-AlbumUri: /api/v2/album/xxxx
X-Smug-Filename: test.jpg
X-Smug-ResponseType: JSON
X-Smug-Version: v2
I have reviewed the documentation at https://api.smugmug.com/api/v2/doc/reference/upload.html and have experimented by passing in static values for ALL of the parameters defined there--and still receive the same message.
How can I diagnose what parameter SmugMug thinks is missing?
FYI, I am definitely in an authenticated OAuth session on my GETs, and can retrieve private objects (private albums and the like). I had been having big problems with POST and binary data, and spend a lot of time working on this. It turns out that rauth is broken, in that it a) throws an error when you post binary data, and b) it does not seem to know how to put the OAuth params into the Authorization header.
Before I was getting responses like:
stat: fail
method: smugmug.images.upload
code 5
message: system error
and
stat: fail
method: smugmug.images.upload
code: 1
message: We're sorry, but you don't appear to be logged in to that account. Please login and try again.
Now that I have found (and I think fixed) some errors in the rauth library I no longer see these errors...so I think I am making progress. Once I have this all working, I can post some details of the fixes here, as well as submit them to the rauth team.
But I don't know what missing parameter SmugMug is complaining about.
Can you give me any suggestions or assistance?
0
Comments
<?xml version="1.0" encoding="utf-8"?>
smugmug.images.upload
It is when I add newline breaks after each parameter in the Authorization header that I get the code: 22
message: missing required parameter response.
So perhaps my root problem is the "system error"...and the "missing required parameter" occurs only when an improperly-formatted Authorization header is sent.
In any case, I appreciate any help or suggestions anyone can offer.
The oauth portion of things is working OK for me. I still haven't got the upload problems resolved however...so I haven't done much more work since my previous post.
Let me know if you have specific oauth questions.