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.

[QUESTION] How to work with form data?

See original GitHub issue

Hello everyone! I need to process form data but I can’t do that with fastapi. To try understand how can I do it I used Postman to send data in different ways: from form-data tab from x-www-form-urlencoded with header “Content-Type: application/x-www-form-urlencoded” with header “Content-Type: application/json” without headers

In any case I have the same result: {“detail”: “There was an error parsing the body”}.

postman

from fastapi import FastAPI, HTTPException, Form

@app.post("/subscription_email")
def subscription_email(*, customers: int = Form(...)):
    return customers

Code based on example from docs.

Please, help me to fix it and understand how to work woth form data from POST requests.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

31reactions
zaitomprocommented, May 8, 2019

@euri10 thank you very much!!! Now it works!!! I checked logs and found reason. The reason is “python-multipart” was not installed. I was surprised because I thought that image contains any requirements for fastapi. Anyway, now I know how to check what’s wrong:) Thank you so much!!!

13reactions
yandongliucommented, Jul 23, 2020

Ran into the same error. Quite dumb to not report the missing package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sending form data - Learn web development | MDN
As we'd alluded to above, sending form data is easy, but securing an application can be tricky. Just remember that a front-end developer...
Read more >
Google Forms guide: How to use Google Forms - Zapier
That's the quickest way to get data into a new or existing spreadsheet: open the spreadsheet where you want the data, start a...
Read more >
Accessing FormData Values - javascript - Stack Overflow
The FormData object lets you compile a set of key/value pairs to send using XMLHttpRequest. Its primarily intended for use in sending form...
Read more >
Form Field Question - Qualtrics
... agility and confidence and engineer experiences that work for everyone. ... Side by Side Question · Autocomplete Questions & Supplemental Data.
Read more >
Question and Data Types in the Form Builder
Forms are made of questions and answers. When adding questions, choose the right Question and Data Types to improve the usability of a...
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