-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Closed
Labels
Description
First check
- [x ] I added a very descriptive title to this issue.
- [x ] I used the GitHub search to find a similar issue and didn't find it.
- [ x] I searched the FastAPI documentation, with the integrated search.
- [ x] I already searched in Google "How to X in FastAPI" and didn't find any information.
- [x ] I already read and followed all the tutorial in the docs and didn't find an answer.
- [ x] I already checked if it is not related to FastAPI but to Pydantic.
- [ x] I already checked if it is not related to FastAPI but to Swagger UI.
- [ x] I already checked if it is not related to FastAPI but to ReDoc.
- [x ] After submitting this, I commit to:
- Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
- Or, I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
- Implement a Pull Request for a confirmed bug.
Example
Here's a self-contained minimal, reproducible, example with my use case:
from fastapi import FastAPI
app = FastAPI()
class Sample(BaseModel):
countryId: int
@router.get("/foo/bar",
response_model=Sample)
def get_sample(sample: Sample):
return {"Hello": "World"}
### Description
* Open the browser and call the GET endpoint `/foo/bar`.
* Pass in JSON body with `{"countryId": 1}`.
* TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body.
### The solution you would like
It doesn't throw the TypeError and allows GET calls to pass in JSON payloads
### Environment
* OS: [e.g. Linux / Windows / macOS]: macOS
* FastAPI Version [e.g. 0.3.0]: 0.60.1
* Python version:
3.7.7
### Additional context
stevesuh, smehrjerdian and musaviOne