Goodreads Developers discussion

96 views
questions > Using review/destroy to delete a review of a book

Comments Showing 1-11 of 11 (11 new)    post a comment »
dateDown arrow    newest »

message 1: by Ryan (new)

Ryan Greenberg (ryangreenberg) | 5 comments I've added support for many API methods to the Ruby Goodreads client but I am stuggling to make a successful call to delete a review.

The review in question is 2417021488 (at https://www.goodreads.com/review/show...)


review id: 2417021488
book id: 234225
user id: 82720595


I have tried every variation I can think of based on the documentation for review.destroy https://www.goodreads.com/api/index#r...

The docs say the URL is /review/destroy/12345?format=xml (with an ID in the URL, as well as an id parameter). My assumption is that this is the review id, but I'm not sure whether I should supply no id param, the same value as an id, or something else. Everything I try results in an error, either Unauthorized or NotFound with an error message about a book id.

Here is a transcript of my requests:

# Here I make an authenticated OAuth query so you can see my client is properly configured


>> OAUTH_GOODREADS_CLIENT.user_id
I, [2018-06-11T19:37:34.766785 #5507] INFO -- : CONNECT: ["www.goodreads.com", 443]
I, [2018-06-11T19:37:34.767387 #5507] INFO -- : GET /api/auth_user
I, [2018-06-11T19:37:35.264870 #5507] INFO -- : BODY: Net::HTTPOK

<?xml version="1.0" encoding="UTF-8"?>
<GoodreadsResponse>
<Request>
<authentication>true</authentication>
<key><![CDATA[Uip8...]]></key>
<method><![CDATA[api_auth_user]]></method>
</Request>
<user id="82720595">
<name>Test Greenberg</name>
<link><![CDATA[https://www.goodreads.com/user/show/8...
</user>
</GoodreadsResponse>


Then I get the current user's review for a book:


>> review = OAUTH_GOODREADS_CLIENT.oauth_request_method(:get, "/review/show_by_user_and_book.xml", {book_id: 234225, user_id: user_id})
I, [2018-06-11T19:41:30.170949 #5507] INFO -- : GET /review/show_by_user_and_book.xml?book_id=234225&user_id=82720595
I, [2018-06-11T19:41:30.833580 #5507] INFO -- : BODY: Net::HTTPOK

<?xml version="1.0" encoding="UTF-8"?>
<GoodreadsResponse>
<Request>
<authentication>true</authentication>
<key><![CDATA[Uip8...]]></key>
<method><![CDATA[review_show_by_user_and_book]]></method>
</Request>
<review>
<id>2417021488</id>

<user>
<id>82720595</id>
...
</user>

<book>
<id type="integer">234225</id>
<title>Dune (Dune Chronicles, #1)</title>
...
</book>
</review>
</GoodreadsResponse>


Then I try to delete the review, putting the review id in the URL, as a parameter, both, with the book_id:


# With review id in URL
>> OAUTH_GOODREADS_CLIENT.oauth_request_method(:delete, "/review/destroy/#{review_id}", { format: 'xml' })
I, [2018-06-11T20:48:36.496325 #5507] INFO -- : DELETE /review/destroy/2417021488?format=xml
I, [2018-06-11T20:48:36.856768 #5507] INFO -- : BODY: Net::HTTPNotFound

<?xml version="1.0" encoding="UTF-8"?>
<GoodreadsResponse>
<Request>
<authentication>true</authentication>
<key><![CDATA[Uip8...]]></key>
<method><![CDATA[review_destroy]]></method>
</Request>
<error>
<code>40004</code>
<generic><![CDATA[One or more parameters contains a value that did not resolve]]></generic>
<detail><![CDATA[Book with that id not found]]></detail>
<friendly><![CDATA[Book with that id not found]]></friendly>
</error>
</GoodreadsResponse>

# With review id as id param
>> OAUTH_GOODREADS_CLIENT.oauth_request_method(:delete, "/review/destroy/#{review_id}", { id: review_id, format: 'xml' })
I, [2018-06-11T20:48:25.657298 #5507] INFO -- : DELETE /review/destroy/2417021488?id=2417021488&format=xml
I, [2018-06-11T20:48:26.143958 #5507] INFO -- : BODY: Net::HTTPNotFound

<?xml version="1.0" encoding="UTF-8"?>
<GoodreadsResponse>
<Request>
<authentication>true</authentication>
<key><![CDATA[Uip8...]]></key>
<method><![CDATA[review_destroy]]></method>
</Request>
<error>
<code>40004</code>
<generic><![CDATA[One or more parameters contains a value that did not resolve]]></generic>
<detail><![CDATA[Book with that id not found]]></detail>
<friendly><![CDATA[Book with that id not found]]></friendly>
</error>
</GoodreadsResponse>


Any suggestions on how to use the /review/destroy API?


message 3: by Ryan (new)

Ryan Greenberg (ryangreenberg) | 5 comments Oleg, thanks for that link. That seems like it’s the web URL that uses cookie-based authentication, or am I misunderstanding? That seems useful if you’re doing a one-off job, but getting users’ login cookies isn’t possible for a client library.


message 4: by Oleg (new)

Oleg Linkin (maledictus) | 60 comments No, this is api url, which you should use with oauth authentication for doing such type of requests. You should make in your library possibility to getting access for user and use credentials from user for your requests


message 5: by Ryan (new)

Ryan Greenberg (ryangreenberg) | 5 comments Hmm, doesn't seem to work for me. With that format I get an HTTP 401 Unauthorized and I'm sure the user OAuth credentials are correct. Do you know of an existing library which makes this request successfully? Maybe I can look at how it implements review deletion.

Request showing that user OAuth credentials are configured correctly. I can edit an existing review for this user:


>> OAUTH_GOODREADS_CLIENT.oauth_request_method(:post, "/review/#{review_id}.xml", {:"review[read_at]" => '2017-06-01'})
I, [2018-06-12T20:47:28.525579 #6140] INFO -- : POST /review/2417021488.xml
I, [2018-06-12T20:47:29.857878 #6140] INFO -- : PARAMS {"review[read_at]"=>["2017-06-01"]}
I, [2018-06-12T20:47:29.857916 #6140] INFO -- : BODY: Net::HTTPOK


<?xml version="1.0" encoding="UTF-8"?>
<review>
<id type="integer">2417021488</id>
<user-id type="integer">82720595</user-id>
<book-id type="integer">234225</book-id>
<read-at type="datetime">2017-06-01T07:00:00+00:00</read-at>
...
</review>



Request to /review/destroy/:book_id?id=:review_id&format=xml fails Unauthorized:


>> OAUTH_GOODREADS_CLIENT.oauth_request_method(:post, "/review/destroy/#{book_id}", {id: review_id, format: 'xml'})
I, [2018-06-12T20:45:17.924128 #6140] INFO -- : POST /review/destroy/234225
I, [2018-06-12T20:45:18.294053 #6140] INFO -- : PARAMS {"format"=>["xml"], "id"=>["2417021488"]}
I, [2018-06-12T20:45:18.294090 #6140] INFO -- : BODY: Net::HTTPUnauthorized

<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>Unauthorized</error>
</errors>



message 6: by Oleg (new)

Oleg Linkin (maledictus) | 60 comments First of all: send DELETE instead of POST like in docs.
Params should be send in url, I think, like in GET request.


message 7: by Ryan (new)

Ryan Greenberg (ryangreenberg) | 5 comments The docs say a lot of things but it seems like they're out-of-sync with the actual implementation (you can see above that I use POST to successfully edit a review even though the docs recommend PUT; in fact, the endpoint errors if you use HTTP PUT).

I've played around with this request a bunch of ways and basically can't get it to work no matter what combination of params I try. If you or anyone else has a working OAuth request, I'll use that to figure out what's wrong. My current thinking is that this endpoint doesn't work.


message 8: by Ryan (new)

Ryan Greenberg (ryangreenberg) | 5 comments It looks like this has been an issue for other folks as well (https://www.goodreads.com/topic/show/...).


message 9: by Jaime (new)

Jaime Stokes | 7 comments I've had the same issues as well.


message 10: by Paul (new)

Paul | 1 comments I can't even get review editing to work. Is the consensus that this API is basically dead?


message 11: by Adam (new)

Adam Sharp | 5 comments Just want to confirm that the issue with PUT requests still seems to be there. @Paul I've got review editing working for POST requests.


back to top