【问题标题】:Automated response download (json) Postman自动响应下载 (json) Postman
【发布时间】:2020-10-10 05:52:54
【问题描述】:

是否可以在 Postman 中创建一个集合,对 API 执行数百个请求并以 json 格式下载所有响应?

如果可以,该怎么做?

如果不可能,我们有哪些可用的工具? (免费和开源)

【问题讨论】:

    标签: json api automation request postman


    【解决方案1】:

    您可以使用 Newman as a library 和 NodeJS fs 模块来执行此操作:

    const newman = require('newman'),
          fs = require('fs');
    
    newman.run({
      collection: '<Collection File Or Link>'
    }).on('request', (err, args) => {
      fs.writeFile(`./${args.item.name}.json`, args.response.stream, (err) => {
        if (err) { 
            console.error(err); 
        }
      });
    });
    

    这将运行您的集合中的所有结果,然后将每个响应保存到 JSON 文件中。 filename 将是请求的名称。

    【讨论】:

    • 完美。谢谢 !!这是我一直在寻找的。​​span>
    猜你喜欢
    • 2020-12-16
    • 2018-12-04
    • 2016-05-01
    • 2022-07-18
    • 2020-04-09
    • 2020-09-16
    • 1970-01-01
    • 2012-12-06
    相关资源
    最近更新 更多