2

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

这是错误 - 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 var。仍然看到同样的错误。

4

1 回答 1

0

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

newman -c Products.postman_collection.json -g globals.postman_globals.json -e Products.postman_environment.json
于 2016-07-13T13:32:37.283 回答