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 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 ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.