有没有办法在Postman的API测试中使用变量名?

时间:2019-04-04 05:30:28

标签: rest api postman web-api-testing

我正在使用邮递员来测试API(这是api测试的新功能,并且刚刚开始对其进行测试),以前它在工作,因为我使用了变量名,它停止工作并显示源代码而不是结果。 />

以前,我使用的是以下API:https://reqres.in/api/users/2
将其引用到变量后,现在为:{{url}}/api/users/2

以前,它向我显示这样的结果:

{
    "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"
        }
    ]
}

1 个答案:

答案 0 :(得分:2)

我假设事先已设置了您的环境变量,但目前尚未设置。只需选择“环境”右上角,或包含所需的值(如果不存在)。

以下是步骤:

enter image description here

好的读物:Postman Variables

相关问题