I'm currently consuming a REST API endpoint for bulk creation of entities via csv file upload.
POST /entity/csv
Content-Type: multipart/form-data
With form-data:
| key | value |
|---|---|
| file | binary |
The backend is currently returning a 400 status code when it can't parse the csv file, however the request sent from the client is actually correct.
From my point of view, this is not the way to go, and it should return a 200, with additional info on the parsing issues. Currently, the parsing errors are on the 400 response body.
Is there any case to be made for the 400 status code when there are failures in the parsing? E.g. "required field is empty - line 43"
What's the consensus around this?
I'm asking this as a frontend developer, because I'm writing frontend logic for displaying the parsing errors to the user inside a catch block, which seems odd to me.