Skip to content
Advertisement

API Requests throwing a 404 error due to bad URL, URL is being changed automatically, what is going on?

I’m having an API pull an ID then use that ID to finish a URL for an API request.

JavaScript

When the URL is tried in my API request I get an HTTP 404 error, when I print url I get a (id,) added to the end of the URL instead of just the ID. Example if I had the ID as 1

url.com/api/client/(1,)

When I print just the variable, print(id) I get just the number value, no added (number,). What is going on here? I also tried using .format() with no change.

Advertisement

Answer

The url parameter in the requests.get call is probably incorrect – an API endpoint rarely ends in a forward slash.

Advertisement