邮差-收集.json -如何通过传递数组使多个请求?(数组中的每一项都是每个请求的查询字符串值)
Postman - Collection.json - How to make multiple requests by passing an array? (every item in the array will be a query string value for each request)
下面是我的邮差收集的json文件。我需要发出大约100个单独的请求,并测试每个请求的响应代码。在每个请求中唯一不同的是查询字符串参数UserID。
那么,我有一个类似于
的数组var users = [123, 124, 125, 126];
我想将这个数组传递到集合中,这样我就不必为每个请求创建单独的'item'
对象。有办法做到这一点吗?我认为'variables'
将是一个很好的地方,但我不确定它是如何工作的。我将很高兴与一个解决方案,使用邮差UI以及。
我可以写一个小的控制台应用程序或一些javascript片段来实现相同的功能,但我想看看是否可以通过postman实现,因为我喜欢使用它。
{
"variables": [],
"info": {
"name": "Test a Set of Users",
"_postman_id": "postman-guid-id",
"description": "",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"name": "User1",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": "tests['"Status code is 200'"] = responseCode.code === 200;"
}
}
],
"request": {
"url": "http://localhost/myAPI/getSomething?UserId=123&isActive=true",
"method": "GET",
"header": [
{
"key": "Accept",
"value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8,,application/json",
"description": ""
},
//all my other request headers - they are the same for all requests
],
"body": {
"mode": "formdata",
"formdata": []
},
"description": ""
},
"response": []
},
"item": [
{
"name": "User2" // everything same as above except for the querystring Parameter UserId
}
]
}
您可以通过Collection Runner实现这一点,并将您的数据作为CSV或JSON文件传入。
https://learning.postman.com/docs/running-collections/working-with-data-files/相关文章:
- 向多维数组添加值和从多维数组请求值
- 使用application/x-www-form-urlencoded使用node.js在post请求中发送数组
- 通过XHR请求将MYSQL数组从PHP返回到Javascript
- 如何显示从Ajax请求返回的数组.使用Yii2
- 使用Javascript数组或JSON来存储AJAX请求的返回值,以备将来使用
- 正在发送请求中包含数组的qx.io.request.Xhr请求
- 为什么我的猫鼬对象 Id 请求返回一个空数组
- 使用AngularJS$http.get在滚动时重复请求JSON数组
- jQuery ajax请求,将索引数组作为关键字字符串
- 如何迭代请求正文中的对象数组
- 使用jQuery.ajax请求向PHP函数发送一个对象数组
- 将jquery ajax请求推入数组时出错
- node.js请求POST数组“;第一个参数必须是字符串或缓冲区;
- 使用Jquery将JSON API请求的元素传递给数组
- 从多个API请求推送到全局数组
- 如何在 Node.js 中的 HTTP 请求后异步导出 JSON 数组
- 来自单个请求的 ajax 请求数组
- 将 jquery get 请求数组传递给 $.when()
- 执行请求数组失败,并多次调用Error: done().映射请求数组不会触发请求
- 邮差-收集.json -如何通过传递数组使多个请求?(数组中的每一项都是每个请求的查询字符串值)