When making a POST, PUT, PATCH request with badly formed body (e.g. wrong types, missing required fields) to an unknown endpoint, should that return 404 or 400?
Example:
- There exists an endpoint
/resource/:resourceId
. - There exists a resource with
resourcedId: 1
. - Endpoint requires
2
fields forPUT
request.enable: boolean
andcount: number
. - Client makes the following request
PUT /resource/2
with body{ enable: 7 }
.
Should the server return 404 (because resource with resourceId: 2
does not exist) or 400 (because body is in invalid format)?