augustin-wien / augustina-backend

An open-source web shop designed for selling magazines on the street.
GNU Affero General Public License v3.0
7 stars 0 forks source link

Change create items to multipart #136

Closed jofmi closed 10 months ago

jofmi commented 11 months ago

Type of change

Description

Create items endpoint now behaves like update items (multipart form)

Checklist:

lebe1 commented 11 months ago

@almoxxx can you write the needed changes in the frontend to have a multipart/form call to create an item instead of a application/json call? :)

almoxxx commented 11 months ago

@almoxxx can you write the needed changes in the frontend to have a multipart/form call to create an item instead of a application/json call? :)

done in a new branch in frontend - pls review if ok :)

jofmi commented 11 months ago

Hi, the CreateItemSimple is only a fallback option if there is an error with parsing the multipart form. The problem was that you did not see the error, which is likely still on the frontend. I added a line to log the error.

jofmi commented 11 months ago

We might consider to delete CreateItemSimple so that there is only one way to update, which is per multipart.

nanu-c commented 11 months ago

The multipart error should send an error 500 to the client and here https://github.com/augustin-wien/augustina-frontend/pull/94 is a frontend branch that corrects the multipart form post, which leads to new problems like:

2023-12-13T16:29:51.389Z        error   1 error(s) decoding:
* 'ID' expected type 'int', got unconvertible type 'string', value: '0'
jofmi commented 11 months ago

Hi, I fixed the typing and removed CreateItemSimple to avoid confusion. Tested with the frontend branch https://github.com/augustin-wien/augustina-frontend/pull/94, and creating an item works now apart from uploading an image!