Postman - 如何使用不同的参数值发送相同的请求如何使用、不同、参数、Postman

2023-09-07 10:58:19 作者:夜眠坂秋.

我创建了一个简单的 API,我想测试具有不同参数值的请求的响应.有没有一种方法可以发送具有不同参数值的相同请求,而无需为每个参数值组合发送不同的请求?

I created a simple API and I want to test the responses for requests with different parameter values. Is there a way to send the same request with different parameter values without sending a different request for every combination of param values?

推荐答案

您可以将参数值保存为 环境变量,然后在参数文本编辑器中使用这种语法{{variableName}}.

You can save your parameter values as environment variables, and then use them in the parameter text editor with this syntax {{variableName}}.

要更新环境变量值,您可以使用 变量编辑器或在 pre-request script 使用这种语法 pm.environment.set("variableName", variableValue).

To update the environment variable values, you can either use the variables editor or set the value in a pre-request script with this syntax pm.environment.set("variableName", variableValue).

这样就可以发送同一个请求,但参数值不同.

In this way, you can send the same request with different parameter values.