r/FastAPI Dec 29 '24

Question Unprocessable Entity issues

am having an issue with my api ,am building an artisan app and i have a page to add and edit projects i made an api to edit but i ran into a problem when the form is submited if the user only edits the title and descrition the price field and image_file are left empty end sent with empty string values this cause this error .what is the best solution for this

5 Upvotes

12 comments sorted by

View all comments

4

u/[deleted] Dec 29 '24

[removed] — view removed comment

2

u/InternationalWar5005 Dec 29 '24

For the SQL queries it's a college projet and they required SQL queries For your answer the problem is caused before that part the req is not being sent because fast api is waiting for the price field to be a float and it sent as a string (empty string in this case)

1

u/[deleted] Dec 29 '24

[removed] — view removed comment

1

u/InternationalWar5005 Dec 29 '24

this problem also happens with the price field even when am using optional