Relative Content

Tag Archive for pythonsqlitesqlalchemyjinja2fastapi

How to trigger a POST request API to add a record in a SQLite database table using FastAPI and HTML forms using Jinja2?

I am trying to submit a HTML form from the browser to create a new user in a SQLite database table. Clicking on the Submit button triggers a POST request using FastAPI and Sqlalchemy 2.0. The API works perfectly when executed from the Swagger UI. But it does not work when triggered from an actual HTML form, returning a 422 Unprocessable Entity error. Below is the code I have used for the same along with the error I am seeing on the browser.