Goodreads Developers discussion

64 views
examples / showcase > Anyone grok the square brackets problem?

Comments Showing 1-10 of 10 (10 new)    post a comment »
dateUp arrow    newest »

message 1: by Shawn (new)

Shawn | 23 comments I think I'm running into the square brackets issue when issuing my user_shelves.xml POST requests as I keep getting "not authorized" and I'm starting to beat my head against a wall. Add a friend works as does basic GETs using OAuth.

I'm using the .NET library Hammock to generate my requests and everything looks fine from a call perspective but then again I don't know what the square bracket issue is and what the GoodReads server expects.

The full request is (with consumer key obviously changed):

POST http://www.goodreads.com/user_shelves... HTTP/1.1
Accept: */*
Referer: file:///Applications/Install/3D67A276...
Content-Length: 24
Accept-Encoding: identity
Authorization: OAuth oauth_consumer_key="XXXXXXXXXXXXXXXXXXXXX",oauth_nonce="hef5vcmu5mw6qg2n",oauth_signature="apfIcMc4%2B4Hc2%2F60HVezOSYtdYI%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1327977976",oauth_token="hTZqHVG5nliRXG5SZtc6jA",oauth_version="1.0"
Content-Type: application/x-www-form-urlencoded
User-Agent: NativeHost
Host: www.goodreads.com
Proxy-Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache

user_shelf%5Bname%5D=buy


message 2: by Gregg (last edited Jan 31, 2012 11:34AM) (new)

Gregg (greggmarshall) | 105 comments I thought I was having a square bracket problem but I got other API calls to work that had square brackets, so I decided that some of the unauthorized results I'm getting may be issues with the APIs.

But in this case I'm able to create shelves without any problems.

I am using URL encoded keys, even though in my testing I found it didn't matter for this API, other method's wanted it and the API seems to accept both.

My call looks about like yours, assuming your OAuth authorization is correct (check and make sure you are using your access token).

user_shelf%5Bname%5D=Sample%20Bookshelf%202

It does appear that the options (exclusive, featured and sortable) don't work on this API call, but seem to work fine when doing the PUT edit method. Not sure what is going on there and haven't heard back from support on that.


message 3: by Michael (new)

Michael Economy (michaeleconomy) Some libraries just work, some require patches to get them to work.

I think there might be opensource .net goodreads code out there you could look at (I think a year ago a guy was developing something).


message 4: by Shawn (new)

Shawn | 23 comments Thanks Michael, it looks like I'm going to have to be the one that patches this particular library. I'm debating writing a quick and dirty request in Ruby just to inspect the request with the exact same params to see where the difference is.

Like Gregg mentioned every other request seems to work, the only ones that don't work for me are those with square brackets so I feel I'm close.

I remember hearing about an open source .NET API but a wee bit of searching hasn't turned it up. I'll dig again.


message 5: by Ettore (new)

Ettore Pasquini Shawn, we had a similar problem for both our iOS and Android apps.

If you are going to patch it yourself, have a look at the code that solved it for us on Android. It's Java but... maybe still useful for .NET?

http://www.goodreads.com/topic/show/7...


message 6: by Shawn (new)

Shawn | 23 comments Thanks for the reference, I'm digging through the Java now and trying to determine where the differences are. If I can just get these last calls working I'll be rocking on my app.


message 7: by Ettore (last edited Feb 01, 2012 08:11AM) (new)

Ettore Pasquini Shawn, I just ran across this topic from another .NET developer:

http://www.goodreads.com/topic/show/3...

Not sure it's helpful to you or if you already saw it, but I thought to mention it anyway.


message 8: by Shawn (new)

Shawn | 23 comments Thanks, I saw it awhile back and they're generating the call by hand without using a library and they're not using OAuth so it wasn't as helpful as I hoped.

For any other .NET developer that may stumble on this that are using the REST library Hammock (https://github.com/danielcrenna/hammock) it appears the square bracket param issue is known: (https://github.com/danielcrenna/hammo...). The dev had to change how he encoded params to work around how Twitter was interpreting the OAuth spec so that could be the source of pain.

I didn't apply the patch to verify but I did change to another lib, RestSharp (https://github.com/restsharp/RestSharp), and that works perfectly. I still want to fix up Hammock as there are some aspects of that library I like better but at least now I have a working vs. non-working sample to play with.

Thanks everyone for the pointers and help, greatly appreciated! I also plan to make my GoodReads lib open source and I'll throw it up on github once it's a little more tidy so at least people have a working example.


message 9: by Michael (new)

Michael Economy (michaeleconomy) Awesome, thanks Shawn!


message 10: by Ettore (new)

Ettore Pasquini Shawn, thanks for sharing your findings! That's greatly appreciated as well.


back to top