API help on expanding related image data

bobgottbobgott Registered Users Posts: 3 Big grins
Hi Folks,
I'm trying to do some analysis via python and the SmugMug API. My scripts are running but as I do need the date/time that a photo was created that requires me to utilize the ImageMetadata. Right now I'm making 1 call to download all image data for an album (not the images themselves) then I need to make another call per image to get the DateTimeCreated from ImageMetadata. Obviously this is S.L.O.W.

Utilizing the API _expand function, I've tested the following url against the Live API browser and it seems to work:
... api.smugmug.com/api/v2/album/zc5wwB!images?_expand=ImageMetadata

but when I use the same url in my python program (via GET method) I get a 401 respnse error:
response: 401
Message: oauth_problem=signature_invalid

Can you let me know what I am doing wrong with the _expand function?


  • Jeffrey FriedlJeffrey Friedl Registered Users Posts: 32 Big grins

    I'm not sure how this would result in an invalid signature, but based upon the "debug_sbs" reported, you're putting "&" before _expand instead of "?"

  • bobgottbobgott Registered Users Posts: 3 Big grins
    I checked my code and in fact the "?" is there on the way up .. for some reason debug_sbs is replacing it with an "&". Don't know why. Then again, I'm getting an invalid signature .. which doesn't occur when I omit the expand.
  • bobgottbobgott Registered Users Posts: 3 Big grins
    Jeffrey, well I figured out the problem. Your observation was a symptom, not the cause. As it turned out I mistakingly put the query part of the expression "?_expand=ImageMetadata" attached to the end of url. With OAuth, the query part must be in the parameters (params - dict) and not url.

    response = self.request('GET', url=url, params=params, headers={'Accept': 'application/json'})
Sign In or Register to comment.