In previous chapters we learned a little about using Postman, and in one of those examples we learned how to create new reviews in the FarmStall API. Creating those reviews required executing a POST operation with a request body. Creating reviews happens to be a critical part of this API, what good is a review centric API without the ability to create reviews!
What we’ll be doing this chapter is describing the operation to create new reviews, ie: POST /reviews. In addition to that, we’re going to take a look at GET /reviews/{reviewId}. This GET operation interests us for two reasons, firstly we’d like to confirm that we did indeed create a new review by fetching the same review back again, and secondly we can see how a path parameter works.
Part of the charm of this approach is using the API itself to verify our work.
Similar to a response body, request bodies are described using OpenAPI’s JSON Schema variant and require a media type to indicate the type of data being sent (ie: application/json).
What we’ll be touching on
- Describe
POST /reviewto create new reviews using a request body
- Create new reviews using Try-it-out in SwaggerEditor
- Describe
GET /review/{reviewId}including its path parameter
- Verify that our newly created reviews are really created using SwaggerEditor’s Try-it-out
Figure 6.1. Postman creating a new review
Figure 6.2. Where we are