如何使用纽曼API获取URL的整个html或json回复 [英] how to get whole html or json repsonse of an URL using Newman API

查看:146
本文介绍了如何使用纽曼API获取URL的整个html或json回复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我从命令行运行时

newman run https://www.getpostman.com/collections/abcd1234

我得到的输出显示失败和执行的统计信息。

I get output displaying the statistics of failed and execute.

但是执行上述Newman查询后,我正在寻找要在终端上打印的URL的完整HTML或JSON响应。如何实现?

But I am looking for the complete HTML or JSON response from the URL to be printed on terminal after executing the above Newman query.How can I achieve this?

推荐答案

我正在使用newman进行Web服务和微服务测试。

I am using newman for webservices and microservices testing. This works fine for me.

summary.run.executions[0].response.text().toString()

完成活动后,您应该能够获得响应。

After done event you should be able to get the response.

d是从Postman导出的集合。

d is the collection exported from Postman.

newman.run({
            collection: d,
            // reporters: 'cli',
            iterationCount: 1,
            timeoutRequest: 10000,
            timeoutScript: 5000,
            delayRequest: 0,
            insecure: false, 
        }).on('done', (err, summary) => {
            if (err || summary.error) {
                console.error('\ncollection run encountered an error.');
                reject(summary.error);
            }
            else {
                var xml = summary.run.executions[0].response.text().toString();
                console.log(xml)
            }
        })
    })

这篇关于如何使用纽曼API获取URL的整个html或json回复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆