Goodreads Developers discussion

38 views
add_review giving me 401 not authorized but only with optional params

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

message 1: by Andy (new)

Andy | 1 comments Hi,
I'm trying to build a client for the API in Emacs Lisp (I know, I know). I've got things mostly working except for the review.create method. It throws a 401 not authorized error when I try to pass more parameters than the required ones ("book_id" and "shelf").

If I pass only "book_id" and "shelf", it works fine. However, when I try to pass the optional parameters — "review[review]", "review[rating]", "review[read_at]" — it throws a 401 not authorized. However, infuriatingly, when I pass "read_at" as the parameter instead of "review[read_at]", it adds the review... but without the date info. Investigating further, passing a random string like "foo" as a parameter shows the same behavior (basically ignoring the parameter) as passing "read_at". Conclusion: the API is recognizing that "review[read_at]" is a real parameter (as opposed to a random string), but for some reason it's saying not authorized.

I know that my application is authorized for at least two reasons: adding a review works when I don't pass optional parameters, and my other OAuth functions (such as adding to shelf) work fine.

The only thing I need from this method is adding a book to the "read" shelf with the date set, so if there's another method to do that, please suggest it.

I have read hints that the square brackets need special encoding. How do I figure out whether I need special encoding in my case?

If it helps, here's a MWE of my code (if you can read / write (e)lisp, let me know!!):
(defun goodreads-add-review (book-id shelf-name &optional date)
"Wrapper for API's review.create method."
(let* ((args
`(("book_id" . ,book-id)
("shelf" . ,shelf-name)
)))
(if (stringp date) ; if the date exists
(setq args (append args `(("review[read_at]" . ,date)))))
(oauth-post-url
goodreads-access-token
"https://www.goodreads.com/review.xml"
args)))


message 2: by Kinghm10 (last edited Sep 02, 2020 02:07AM) (new)

Kinghm10 | 2 comments I do have the same problem. I am Authenticated using the developer key and I got the user id and everything works fine. however, when I do a post request "add to shelf" it gives me 401 not authorized error. the strange thing is that when I tried this request through the browser it works!

By the way, all Get requests that require Authentications work fine, but post requests don't

I do not know what is the issue


back to top