and receive a response. If you haven’t already done this, go ahead and try it out. Hit your favorite endpoint and inspect your response. Play around with different HTTP verbs, headers, and auth types.
If you don’t have a favorite endpoint at the ready, the
is included in your Postman app download. It’s a good way to try out different request types.
#2 Write a test
For a lot of people, Postman is synonymous with API testing. For some, that might mean sending and inspecting a response like we did in Step #1. It could also mean writing assertions to validate that an endpoint is returning the appropriate responses. It can also mean setting up logic to mirror your workflow and automating the tests.
is to take a look at the snippets on the right side of the Tests tab. Clicking on a snippet will append the JavaScript code into the editor. If you’re comfortable writing your own tests, or updating the boilerplate code, the world is your oyster!
Send your request again, and now you can see the results of your test on the bottom, under the corresponding Tests tab in the response viewer.
Collections are the cornerstone for all advanced Postman features. At its simplest, a collection is a way to group together requests and run those requests in a pre-determined sequence. In all its glory, a collection is an executable description of an API.
, and maybe add a few more if you feel like it. Click on the chevron (>) next to the collection name, and hit the blue Run button to open the collection runner in a new window.
When you run your collection in the Postman app with the
, you can store information in key-value pairs within a Postman environment. Let’s try it out.
Use the pm.* API to set and get environment variables in the scripting sections. Under the Tests tab, set an environment variable with pm.environment.set("variableName", variableValue). Now that you’ve initialized the variable, you can use this value in any subsequent requests in the text sections like {{variableName}} or in the scripting sections like pm.environment.get("variableName").