request params is not support #8716
-
First Check
Commit to Help
Example Codeclass Item(BaseModel):
name: str
age: int
height: float
app = FastAPI()
@app.get("/hh")
async def update_item(item: Item): # item需要与Item对象定义保持一致
return {
"method": 'get',
"people_name": item.name,
"people_age": item.age,
"people_height": item.height
}Descriptionthis request method is GET so that is not support Operating SystemWindows Operating System DetailsNo response FastAPI Version0.63.0 Python VersionPython 3.10.0 Additional Contextemo |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
|
You have wrong code in your handler, pydantic model is used for body parameters from JSON in POST request. @app.get("/hh")
async def update_item(name: str, age: int, height: float):
return {
"method": 'get',
"people_name": item.name,
"people_age": item.age,
"people_height": item.height
}More on query parameters in docs. |
Beta Was this translation helpful? Give feedback.
-
# to resolve GET method
item: Item = Depends(Item) |
Beta Was this translation helpful? Give feedback.
-
thank you your method is right you is my angel baby |
Beta Was this translation helpful? Give feedback.
-
i know what you say , see the panla comments, you will know other way to deliver params of GET |
Beta Was this translation helpful? Give feedback.
-
|
@panla interesting method didn't know about it, thank you! @yztdemo I must still admit that for clarity if you want to update something it is better to not use GET method, cause it's misleading. |
Beta Was this translation helpful? Give feedback.
-
name: Optional[str] = Query('', title='name') |
Beta Was this translation helpful? Give feedback.
-
|
Since FastAPI 0.115.0 you can modify your code by adding |
Beta Was this translation helpful? Give feedback.

Since FastAPI 0.115.0 you can modify your code by adding
Querylike shown below to make it working: