集合在Postman中运行,而不在Newman中运行 - 无效的URI错误

时间:2016-07-13 04:17:13

标签: json postman newman

我有一个在Postman中运行的集合,而不是在纽曼。

这是错误 - newman -c Products.postman_collection.json -e Products.postman_environment.json

Iteration 1 of 1
RequestError: [d395a91e-4220-4c2c-81bd-cff20cac63b8] 'Product Detail' terminated. Complete error: 
Error: Invalid URI "http:///%7B%7BbaseUrl%7D%7D/shop/%7B%7BapiVer%7D%7D/products/samsung-ypk3?client_id=%7B%7BclientId%7D%7D"
    at Request.init (/usr/local/lib/node_modules/newman/node_modules/request/request.js:288:31)
    at new Request (/usr/local/lib/node_modules/newman/node_modules/request/request.js:142:8)
    at request (/usr/local/lib/node_modules/newman/node_modules/request/index.js:55:10)
    at Object.jsface.Class._execute (/usr/local/lib/node_modules/newman/src/runners/RequestRunner.js:181:26)
    at Timeout._onTimeout (/usr/local/lib/node_modules/newman/src/runners/RequestRunner.js:87:20)
    at tryOnTimeout (timers.js:224:11)
    at Timer.listOnTimeout (timers.js:198:5)
RequestError: [f909ee1b-334a-40ed-94ec-4398c12bd442] 'Product Images' terminated. Complete error: 
Error: Invalid URI "http:///%7B%7BbaseUrl%7D%7D/shop/%7B%7BapiVer%7D%7D/products/samsung-ypk3/images?client_id=%7B%7BclientId%7D%7D"
    at Request.init (/usr/local/lib/node_modules/newman/node_modules/request/request.js:288:31)
    at new Request (/usr/local/lib/node_modules/newman/node_modules/request/request.js:142:8)
    at request (/usr/local/lib/node_modules/newman/node_modules/request/index.js:55:10)
    at Object.jsface.Class._execute (/usr/local/lib/node_modules/newman/src/runners/RequestRunner.js:181:26)
    at Timeout._onTimeout (/usr/local/lib/node_modules/newman/src/runners/RequestRunner.js:222:20)
    at tryOnTimeout (timers.js:224:11)
    at Timer.listOnTimeout (timers.js:198:5)

Postman中的URI看起来像这样 -

http://{{baseUrl}}/{{apiType}}/{{apiVer}}/products/{{productId}}?client_id={{clientId}}

当我打开集合的JSON文件时,这就是URI的样子 -

"url": "http://{{baseUrl}}/{{apiType}}/{{apiVer}}/products/{{productId}}?client_id={{clientId}}"

关于可能导致无效URI错误的任何想法?

将newman调用更新为以下内容 -

newman -c Products.postman_collection.json -e globals.postman_globals.json -e Products.postman_environment.json

其中第一个env var文件是Postman全局变量,第二个env var文件是集合特定的env变量。仍然看到同样的错误。

1 个答案:

答案 0 :(得分:0)

必须使用-g选项传递globals文件。所以最后的命令看起来像 -

newman -c Products.postman_collection.json -g globals.postman_globals.json -e Products.postman_environment.json
相关问题