Error getting request body: The `python-multipart` library must be installed to use form parsing.

See original GitHub issue

(venv) G:\projects\python\fastprojects>pip list

python-dateutil 2.8.1 python-multipart 0.0.5 rope 0.17.0

@app.post('/token', tags=['safe'])
async def login(form_data: OAuth2PasswordRequestForm = Depends()):
  print('form_data', form_data)
  user_dict = fake_users_db.get(form_data.username)
  if not user_dict:
    raise HTTPException(
      status_code=400,
      detail='Incorrect username or password'
    )
  user = UserInDB(**user_dict)
  hashed_password = fake_hash_password(form_data.password)
  if not hashed_password == user.hashed_password:
    raise HTTPException(
      status_code=400,
      detail='Incorrect username or password'
    )
  return {'access_token': user.username, 'token_type': 'bearer'}

I don’t know how to troubleshoot this problem

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
zackeescommented, Jul 22, 2022

The error output instructs the user to install python-multipart, instead of multipart.

It’s also possible that both need to be installed.

1reaction
tiangolocommented, Nov 11, 2020

Thanks for the help here @Kludex ! 👏 🙇

I understand you solved your problem, so thanks for reporting back and closing the issue @q98765543221 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

The `python-multipart` library must be installed to use form ...
The full stack is: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/uvicorn/protocols/http/httptools_impl.py" ...
Read more >
Errror parsing data in python FastAPI - Stack Overflow
I acomplished to figure out, it was because when FastAPI was installed, it didn't install python-multipart, so with this package missing ...
Read more >
Form Data - FastAPI
To use forms, first install python-multipart . ... to receive as JSON, as the request will have the body encoded using application/x-www-form-urlencoded ...
Read more >
python-multipart - PyPI
A streaming multipart parser for Python.
Read more >
tiangolo/fastapi - Gitter
From what I saw the python-arango library makes use of a requests. ... the test getting message like {'detail': 'There was an error...
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