Skip to content
Related Articles
Open in App
Not now

Related Articles

How to Perform POST Request in Postman with Test Validation?

Improve Article
Save Article
Like Article
  • Difficulty Level : Medium
  • Last Updated : 23 May, 2022
Improve Article
Save Article
Like Article

Postman is an API(application programming interface) development tool that helps to build, test, and modify APIs. Almost any functionality that could be needed by any developer is encapsulated in this tool. It is used by over 5 million developers every month to make their API development easy and simple. It has the ability to make various types of HTTP requests(GET, POST, PUT, PATCH), save the environments for later use, and convert the API to code for various languages(like JavaScript, and Python). For getting started with this, we need to install the postman in our system.


Open this link and download the Postman.


After completing the download install the software in the system. In this article, we are going to POST the data using the URL “” and write the Test validation script to run the tests for API.

POST Method

In the POST method, we are passing some data to the API. In this example we are sending the email and password for login API, if this is valid we will receive a token for login.

Steps for creating the POST method:

  1. Create a new workbook
  2. Create a Collection in that workbook.
  3. After creating the collection, now create a POST method into it.
  4. Add the URL.
  5. Move to the Body tab and select the option raw.
  6. After that, choose JSON from the dropdown.

Now, we have to enter the valid username and password in the JSON format in the body.


JSON Data:

“email”: “”,
“password”: “cityslicka”

If the mail and password are valid we get the token as a response and status code as 200.


otherwise, we will get an error.


Adding Test validation

  • Now navigate to the tests tab.
  • After that an example for writing a test to this POST request, we have to check the response code is 200, and check the response body has the “token” present in it.

tests[“Checking response code”]=responseCode.code==200;
tests[“validating token presence”]=responseBody.has(“token”);

After the tests are written save the collection and now run it by clicking the send button.


My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!