OperationCode/resources_api

`/apikey` endpoint returns a 400 when it should return a 422

aaron-junot opened this issue · 1 comments

When you send a request to the Create Resource endpoint that doesn't include a JSON body, you get a 422 response with a helpful error message informing you that a json body is required to use this endpoint. See

resources_api/app/utils.py

Lines 157 to 160 in aa3e33d

if not json:
message = "A JSON body is required to use this endpoint, but none was given"
validation_errors['errors']['message'] = message
return validation_errors

When you make a request to the /apikey endpoint without a JSON body, you get a cryptic error message and a 400 response. We should catch this error and return a similar response that you'd get from the Create Resource endpoint.

While we're in there, we should verify that the intended error message is returned when the request body is blank or an empty object ({}) on all endpoints that require a JSON body in the request.

Closed in #185