[QUESTION]Using a single Body parameter, the JSON format will report an error
See original GitHub issueDescription
Using a single Body parameter, the JSON format will report an error
Additional context
@router.post("/test/")
async def test(abd: str=Body(...)):
print(abd) ---error
@router.post("/test/")
async def test(abd: str=Body(...), acd: str=Body(...)):
print(abd) ---right
Using a single Body parameter, the JSON format will report an error
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
I've received an "Invalid JSON string" error. What do I do?
What do I do? An invalid JSON error can occur for many reasons. The most common issue is usually associated with a file...
Read more >SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >Measurement Protocol Reference - Google Developers
Data is sent to Google Analytics using the Measurement Protocol Data in two parts: Query parameters; A JSON POST body. query parameters. Parameter...
Read more >Geopoints—ArcGIS Survey123 | Documentation
Each repeat in a survey can also have more than one geopoint, geotrace, ... displays WGS84 latitude and longitude values in degrees/minutes/seconds format....
Read more >fastapi - How to read body as any valid json? - Stack Overflow
You can find nearly everything inside the Request object. You are able to get request body with request.json() , which will give you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In my opinion, the condition of your solution is already different from the problem you met, which is “Single parameter declared with fastapi.Body requests str formatted rather than json formatted request body”.
I read the official doc singular-values-in-body, but the demo contains extra paramters(request param, pydantic model).
In my case, I have many apis that needs only a single post body param.
So Is there a way to declare a single param in body of a post api without using pydantic?
Thanks for the discussion here everyone! And thanks @wxq0309 for closing the issue and reporting back your solution. 👍