Validating data type
We have completed our first scenario, so let's move on to our second and third scenarios. As a reminder, they are as follows:
- If the client sends aÂ
POST
 request toÂ/users
 with a payload that is not JSON, our API should respond with aÂ415 Unsupported Media Type
 HTTP status code and a JSON object payload containing an appropriate error message. - If the client sends aÂ
POST
 request toÂ/users
 with a malformed JSON payload, our API should respond with aÂ400 Bad Request
 HTTP status code and a JSON response payload containing an appropriate error message.
Â
Start by adding the following scenario definition to the spec/cucumber/features/users/create/main.feature
file:
Scenario: Payload using Unsupported Media Type If the client sends a POST request to /users with an payload that is not JSON, it should receive a response with a 415 Unsupported Media Type HTTP status code. When the client creates a POST request to /users And attaches a generic non-JSON payload ...