surender pal
surender pal

Reputation: 515

Is there any way to use variable name in API testing in Postman?

I'm testing the API using postman (new to the api testing and has just started to test it), it was previously working as I use the variable name it stops working and displaying source code instead of the result.

Previously I'm using this API: https://reqres.in/api/users/2
After referring it to the variable it is now: {{url}}/api/users/2

Previously it is showing me result like this:

{
    "page": 2,
    "per_page": 3,
    "total": 12,
    "total_pages": 4,
    "data": [
        {
            "id": 4,
            "first_name": "Eve",
            "last_name": "Holt",
            "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/marcoramires/128.jpg"
        },
        {
            "id": 5,
            "first_name": "Charles",
            "last_name": "Morris",
            "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/stephenmoon/128.jpg"
        },
        {
            "id": 6,
            "first_name": "Tracey",
            "last_name": "Ramos",
            "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/bigmancho/128.jpg"
        }
    ]
}

Upvotes: 0

Views: 563

Answers (1)

Divyang Desai
Divyang Desai

Reputation: 7864

I assume that, beforehand, your Environment Variable was set, presently it isn't. Simply select the Environment right upper corner or include required value if its not present.

Here are the steps:

enter image description here

Good reads: Postman Variables

Upvotes: 3

Related Questions