-
-
Notifications
You must be signed in to change notification settings - Fork 9k
How to pass list in query parameters? #50
Description
Description
I need to support several query parameters with same name in GET route. Typical request looks like this:
http://localhost/item?num=1&num=2
I configured a route
@app.get("/item", content_type=UJSONResponse)
async def get_part(num: list):
found = False
for i in num:
if i in some_data:
found = True
break
return {"found": found}
The idea is, that I can pass several numbers to check, if they exist in some_data. In my opinion, it is not a good idea to get numbers from body here, because it is a simple GET request, but in current version application expects argument "num" in body, so on my request (written above) I receive a response
{"detail":[{"loc":["body","num"],"msg":"field required","type":"value_error.missing"}]}
As I know, it is not restricted to pass several query parameters with the same name in an HTTP request by any specifications, so I would like to ask, is it possible to configure a route in FastAPI, which will be able to parse several query parameters with the same name?