Goodreads Developers discussion

78 views
review.update and PUT question

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

message 1: by Ben (new)

Ben Schuster | 5 comments I'm a little confused on how to use the api to update a review.

The documentation says that the call needs to be a PUT method, but if I'm unsure what should be in the put file.

My guess would be XML containing the update to the review. But what would be the syntax?

An example url with params, and put file would be greatly appreciated.

Thanks
-Ben


message 2: by Michael (new)

Michael Economy (michaeleconomy) No xml, just parameters. I think you're donig the same thing as review/create except with a different url and a different http method.


message 3: by Ben (new)

Ben Schuster | 5 comments Oddly enough, I haven't been able to get review.create to work either.

If I have already added the the book to the a shelf, I am returned "Request failed with code 422: Book has already been reviewed by this user", but if I choose a book that isn't in any of my shelves I get a "Request failed with code 500: ".

Maybe there's something wrong with my params?
I've tried calling it in 2 different ways, but both return the same 422 or 500 error.

$req = new OAuthRequester(
"http://www.goodreads.com/review.xml",
"POST",
array(
'shelf' => $shelf_name,
'book_id' => $book_id,
'review' => array(
'review' => $review_text,
'read_at' => $review_date,
'rating' => $rating
)
)
);

and

$req = new OAuthRequester(
"http://www.goodreads.com/review.xml",
"POST",
array(
'shelf' => $shelf_name,
'book_id' => $book_id,
'review' => $review_text,
'read_at' => $review_date,
'rating' => $rating
)
);

I know there must be some obvious mistake in there, but I haven't been able to suss it out.


message 4: by James (last edited Nov 20, 2009 10:44AM) (new)

James Van metre | 17 comments I believe it is the second way, but instead of
'shelf' => $shelf_name,
'book_id' => $book_id,
'review' => $review_text,
'read_at' => $review_date,
'rating' => $rating

try

'shelf' => $shelf_name,
'book_id' => $book_id,
'review[review:]' => $review_text,
'review[read_at:]' => $review_date,
'review[rating:]' => $rating

**for some reason it is adding : into the [ :] ... don't do those


message 5: by Michael (new)

Michael Economy (michaeleconomy) sorry, my parser sucks :)


message 6: by Michael (new)

Michael Economy (michaeleconomy) Thanks James!


message 7: by Ben (new)

Ben Schuster | 5 comments Ah, I get it now.
Now I've got both create and update working.

Thanks.


message 8: by David (new)

David Robins (dbrobins) | 24 comments Review update (/review/.xml URL) used to work for me. In fact, it worked without using a PUT request. Now it doesn't work whether or not I use a PUT request. The data (book_id, shelf, review[review|read_at|rating:]) is being sent in the body encoded as application/x-www-form-urlencoded, with the proper OAuth Authorization header. I get back a 401 (authorization) error with useless message "Invalid OAuth Request". Same setup (not PUT) works fine for review.create, so my credentials are fine.

A little more detail beyond "Invalid OAuth Request" would be wonderful. I've tried the request several times, so it's not the old case of the APIs just randomly failing and the same request working later.

The 401 response does not include a WWW-Authenticate header (which the HTTP RFC says it MUST have). What's going on here?


message 9: by James (new)

James Van metre | 17 comments I am getting the same result as David.


message 10: by Ben (new)

Ben Weiner (lostinpatterns) | 24 comments David and James: does this work if you POST to that resource rather than PUT?


message 11: by James (last edited Nov 23, 2009 05:23PM) (new)

James Van metre | 17 comments No when I try to POST, I get a page with: The resource you requested doesn't exist. "Please check the url again, or go to the home page." Yet I can make other POST calls fine, like adding a new book, or changing shelves for a book, or updating user status. The only thing I can't do is add a review, or update the user rating because both of these rely on this method.


message 12: by Ben (new)

Ben Weiner (lostinpatterns) | 24 comments Going to look into this first thing tomorrow and then get back to you.


message 13: by Ben (new)

Ben Weiner (lostinpatterns) | 24 comments James - are you using HMAC-SHA1 to generate the signature? When you PUT to /review/.xml, the error in the logs is invalid signature method. Make sure you have oauth_signature_method="HMAC-SHA1" as part of the Authorization header.


message 14: by James (new)

James Van metre | 17 comments Yes, I am using HMAC-SHA1, the only problem is that I am implementing the PUT section myself, the other two methods already worked.. so I am probably just generating the signature wrong. Thank you very much for the response!


message 15: by James (last edited Nov 25, 2009 07:42AM) (new)

James Van metre | 17 comments I switched my Authorization header from multiple lines to a single one and now all works as it is supposed to! Thanks for the help!


message 16: by Ben (new)

Ben Weiner (lostinpatterns) | 24 comments Great to hear James!


back to top