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

问题描述 投票:0回答:1

我正在使用postman测试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"
        }
    ]
}
rest api postman web-api-testing
1个回答
2
投票

我认为,事先,您的环境变量已设置,目前它不是。只需选择右上角的环境或包含所需的值(如果不存在)。

以下是步骤:

enter image description here

好读:Postman Variables

© www.soinside.com 2019 - 2024. All rights reserved.