3

I can create albums, using the requests and oauth-hook modules just fine, but I can't seem to get a name working. Check out the docs here: http://api.imgur.com/resources_auth#account_albums . I'm using Windows7x64 Python2.7, requests version 0.21.1 and oauth-hook version 0.4.0

Strangely, using the same approach to name an image when I upload it, the script works just fine. Here's the relevant code:

client = requests.session(hooks={'pre_request': authorizedHook})

url = r'http://api.imgur.com/2/account/albums.json'

parameters = {'title': 'ALBUMTITLEHERE'}

r = client.post(url, data=parameters)

which returns something like this, once I load it into json:

    Created Album data:
    {u'albums': {u'anonymous_link': u'http://imgur.com/a/i3Gal',
                 u'cover': u'',
                 u'datetime': u'2012-05-24 02:34:42',
                 u'description': u'',
                 u'id': u'i3Gal',
                 u'layout': u'blog',
                 u'link': u'http://tankorsmash.imgur.com/1B498',
                 u'order': 0,
                 u'privacy': u'public',
                 u'title': u''}}    

What I was expecting was a named gallery called ALBUMTITLEHERE. But created an untitled one instead. What am I doing wrong?

Unrelated: The Stats API doesn't seem to be returning anything at all for me, but I'm not sure that's relevant.

TankorSmash
  • 12,186
  • 6
  • 68
  • 106
  • Does requests have a debug mode? I would guess it would be clear if you had a look at the data that was actually being sent over by your request. There is sample code at the documentation link you included. – valdarin May 26 '12 at 04:11
  • @valdarin A week later, I can see that my comment didn't get posted. I didn't find anything that stuck out to me. – TankorSmash Jun 01 '12 at 04:29

1 Answers1

5

Edit:

I've tried it myself now for quite some time, tried nearly every possible combination of parameters sent as http url parameter, post (json, urlencoded, even xml)... even analyzed raw requests in wireshark - everything works as it should.

But no luck, it doesn't work.

I'm quite sure this is a bug in the API itself. It's also impossible to change the title of an existing album.

So my previous response doesn't apply.

mata
  • 67,110
  • 10
  • 163
  • 162
  • Can you confirm it works on your end? I am getting `This method requires authentication` errors when I change the `Content-type` to `application/json`, and transform the params the json. Removing that header and using the old param dict still works as usual. – TankorSmash May 26 '12 at 16:00
  • As long as the OAuth hook has `header_oauth = True` I don't get that authentication error. But then the returned album is still untitled, even with the json params and header. Though the `stats` api works but that could be on their end, since the browser page isn't blank any more either.. – TankorSmash May 26 '12 at 16:08
  • Alright, thanks for the help, here's the bounty, since you put in a good deal of time into this. Thanks again. – TankorSmash Jun 01 '12 at 14:26