Using Postman to play with API
If you are developing your own API (whatever the language) or if you need to consume some, Postman can be really handy.
Calling an API and getting the response is one thing, quite simple in fact, but a nice feature of Postman is the ability to validate the response like making sure the returned type is, f.i. application/json
, the HTTP status code is 200, the response body is a JSON object (or an XML string), that the body contains some required information and so on.
You can also validate the response against a given schema to make sure the structure is well the one expected.
In this article, we'll use Postman like a unit test tool i.e. run checks on our own API and make a lot of assertions. This is improving the quality of your code by highlighting potential errors and, for any refactoring you'll do in the future, by running the tests again, you'll make sure you've not broken something; that you don't have any regression. Make sure you've not broken an API when you upgrade some code is gold.