How to get value from response and refer in a request in Postman

First I will create a get request as follows.

Request URL: https://reqres.in/api/users?page=2

And again I’ll add a second request as an update user.

Request URL: https://reqres.in/api/users/2

Request body:

{

“name”: “morpheus”,

“job”: “zion resident”

}

Now let’s use environment variables to parameterize the value to be referred.

Let’s update fetched values in environment variables. If we want to fetch “Lindsay”, in the test section we can add javascript snippets as follows.

Here we have given the json path of “Lindsay” as data[1].first_name. Once I run this,

Now let’s set it as the environment variable.

Here you can see that the value “Lindsay” has been set as an environment variable value.

Now let’s run the second API and fetch the value.

Here also you can see that the value “Lindsay” has been taken properly.

--

--