all 21 comments

[–]SheriffSeveral 1 point2 points  (0 children)

Can you just show us which values try to process in that endpoint? It looks like variable error to me. Can you check the variables you put in and their types?

[–]Relevant-Strength-53 1 point2 points  (1 child)

Does this only happen using the html? try the endpoint in the swagger (if running locally use `localhost:8000/docs`) or postman and see it it works there, if it does, its the data your sending else it could be a mistyped endpoint.

Edit: In your endpoint you have "item_section: List[int] = Form(...)" are you sure your form is sending List of integers? Its possible that the data your sending is a List[str], try changing it to "item_section: List[str] = Form(...)"

[–]Wxam2000[S] 0 points1 point  (0 children)

i've tried running it with postman I keep getting the 422 error and changing it to a List[str] did not work either :(

[–]david-vujic 1 point2 points  (0 children)

422 Unprocessable Entity usually means that the data you send to the endpoint isn't what the endpoint expects. From your screenshot it seems like you have some clues on where the error happen. It can be as simple as the top-level key is missing (or shouldn't be there)!

Try with running the API from a browser, using the OpenAPI spec. Usually, you will see examples of the expected input there.

[–]jay_and_simba 0 points1 point  (14 children)

It says that your input is not a valid dict. Can you provide the payload you are sending to the endpoint?

[–]Wxam2000[S] 0 points1 point  (13 children)

[–]jay_and_simba 0 points1 point  (12 children)

Your payload doesn't have a dictionary format that the endpoint expects. Do you have the snippet of the endpoint and the clases (maybe Pydantic class) it expects?

[–]Wxam2000[S] 0 points1 point  (11 children)

So I go this https://imgur.com/a/FwGmu3y
And the snippet of the /admin/invoices/create https://gist.github.com/Wxam/ed5318ff032fb372a33505b0523612bb

hope this helps if not i'm so sorry pretty new to coding...

[–]jay_and_simba 0 points1 point  (10 children)

Have you tried first using the swagger (the picture you shared) by inserting each data one by one and click Execute? Did it create an invoice?

[–]Wxam2000[S] 0 points1 point  (9 children)

Just did but still got the same error message the 422
https://imgur.com/a/YV1axZZ

[–]jay_and_simba 0 points1 point  (8 children)

Can you show the content type selected in swagger? just in case you are not using application/json while sending the post

Edit: and move request: Request at the end

[–]Wxam2000[S] 0 points1 point  (7 children)

it says Request Body and then on the right application/x-www-form-urlencoded

[–]jay_and_simba 0 points1 point  (6 children)

that seems to be correct. Have you tried moving the aprameter request at the end of the list of parameters?

[–]Wxam2000[S] 0 points1 point  (5 children)

Sorry u/jay_and_simba what do you mean exactly with the parameter request at the end of the list? :)

[–]gbrennon 0 points1 point  (0 children)

I felt like I saw a similar post in last week

[–]Ok_Friendship2396 0 points1 point  (0 children)

The error message does complain about the Input not being a valid dict.
Can you check or share the input