0

I have tested my function separately in python and it worked:

def get_goodreads_review(isbn): return requests.get(GOOD_READ_URL, params={"key":KEY, "isbns": isbn})

if I set isbn = "1416949658" res=get_goodreads_review(isbn)

I can get the result and the status code is 200. However, when I did this: book=db.execute("SELECT * FROM books WHERE _id=:book_id", {"book_id":book_id}).fetchone() isbn=book.isbn res=get_goodreads_review(isbn)

I got a status code of 404 (and I have tried doing isbn=string(book.isbn) as well) I have also checked that book.isbn is "1416949658"

So now I have done some more digging: enter image description here

and the result is enter image description here

So the program first directly use "1416949658" as the isbns parameter of the requests and everything is fine. However, when we get the isbn from the database and as can be seen from the output, the new isbn (line 37) is the same but when it is compared to the string "1416949658", the result is false and also when it is used as isbns parameter, the status code became 404.

Can someone shine a light on this?

Thanks. Hoi Fei

Any idea?

Thanks. Hoi Fei

0
0

Problem solved. After more digging using print(repr()), I found that the isbn returned from database had a number of whitespaces at the end compared to the string literal. So I used strip() and problem solved.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .