Postman is a test tool to makes API development faster, easier, and better for development teams. It lets you automate your API tests and get early feedback in the development stage. Data extraction in postman article will cover two feature:

  • Data extraction from a web service
  • How to use this data in another web service call

How to Extract Data from JSON response in Postman?

All Postman request has a section called “Tests”. This is where you do all scripting for data extraction. This is the basic command to extract response body into a variable.

Now your response body is stored in a variable called jsonData.

Now you are able to fetch any data from the response by using JsonPath expressions.

Our response is below:

So we extract the authentication token by using below expression.

Now, authentication string is stored in a global environment variable. This variable’s name is “access_token” for this example.

data extraction in postman

How to Use Extracted Data?

We want to use globally set value in another authenticated web service call. Let’s do it.

All you need to do is use {{variable_name}} convention to use the extracted value in a Potman request. You can use it in a URL, Header or file body. All you need to do is using the same convention.

Now you can your run tests and see that your second web service will use the authentication token fetched from the first service.