question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`request.body()` not works

See original GitHub issue

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn’t find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google “How to X in FastAPI” and didn’t find any information.
  • I already read and followed all the tutorial in the docs and didn’t find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

from fastapi.exceptions import RequestValidationError
from fastapi.requests import Request

...

@app.exception_handler(RequestValidationError)
async def validation_exception_handler(request: Request,
                                       exc: RequestValidationError):
    print(await request.body())

Description

I made POST /bla-bla-bla with invalid data, when the error occurred I can’t see the body of the request, swagger endlessly loads something

Operating System

macOS

Operating System Details

MacOS 12.1 Monterey

FastAPI Version

0.70.1

Python Version

3.9.9

Additional Context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
upeshphablecommented, Jan 27, 2022

Refer to issue #394

1reaction
panlacommented, Jan 18, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

java - @RequestBody not working on Rest service
My problem is that I am going nuts because the annotation @requestBody appears to work wrong. This is my service: @ResponseBody @RequestMapping( ...
Read more >
Add a Request Body to a POST Request | API Connector
If your POST request isn't working, a likely cause is a mismatched content type. Try adding in a content type into the header...
Read more >
Request.body - Web APIs - MDN Web Docs
The read-only body property of the Request interface contains a ReadableStream with the body contents that have been added to the request.
Read more >
Why my request.body is empty while request.params in not?
We can't see the request parameters on your Postman screenshots nor the logs in your code but the port you listen to with...
Read more >
HTTP Request body not working - Activities - UiPath Forum
I am trying to use the HTTP request. Authentication is ok but I can't get the body correct. I found posts about using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found