Uploading with API v2 (especially with rauth in Python)

drueterdrueter 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?

Comments

  • drueterdrueter Registered Users Posts: 4 Beginner grinner
    edited November 2, 2015
    FYI, if the Authorization header does not have newline breaks after each parameter (as I believe is the correct way to format them), SmugMug returns an error:

    <?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.
  • mattdmmattdm Registered Users Posts: 16 Big grins
    edited November 25, 2015
    I'm having similar problems, although I'm trying to use the non-upload portion of the API, which is very different from the upload portion. Are your fixes to rauth upstream?
  • drueterdrueter Registered Users Posts: 4 Beginner grinner
    edited November 25, 2015
    mattdm wrote: »
    I'm having similar problems, although I'm trying to use the non-upload portion of the API, which is very different from the upload portion. Are your fixes to rauth upstream?

    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.
  • mattdmmattdm Registered Users Posts: 16 Big grins
    edited November 25, 2015
    Thanks — I got that part figured out, where the root cause turned out to be not explicitly passing "Content-type: application/json" when using PATCH. Sounds like whatever problems you have are different, though.
Sign In or Register to comment.