Skip to content
Discussion options

You must be logged in to vote

When you write this

params = {"item_id":0}
r=requests.get(url, params=params)

requests is going to create a request to http://127.0.0.1:8000/item?item_id=0

but you have told FastAPI that you want item id from the path by putting it in the brackets in the path

@app.get("/item/{item_id}",...

which is a request like this http://127.0.0.1:8000/item/0

If you want the endpoint to work like your example request you need to use query params https://fastapi.tiangolo.com/tutorial/query-params/#query-parameters

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jonathanbouchet
Comment options

Answer selected by jonathanbouchet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants