【问题标题】:Collection runs in Postman, and not in Newman - Invalid URI error集合在 Postman 中运行,而不是在 Newman 中运行 - 无效的 URI 错误
【发布时间】:2016-11-15 12:08:34
【问题描述】:

我有一个在 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。仍然看到同样的错误。

【问题讨论】:

    标签: json postman newman


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2017-11-03
      • 2017-08-17
      • 2022-06-22
      • 2021-08-25
      • 2016-09-24
      • 2018-05-26
      • 2016-07-24
      • 2018-09-20
      • 2022-01-18
      相关资源
      最近更新 更多