如何在 Postman 中获取请求参数? [英] How to get to request parameters in Postman?

查看:88
本文介绍了如何在 Postman 中获取请求参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Postman 编写测试,它通常很容易工作.但是,我现在想访问请求的一些数据,准确地说是查询参数.您可以通过返回字符串的request.url"对象访问请求 URL.Postman 中是否有一种简单的方法来解析此 URL 字符串以访问查询参数?

I'm writing tests for Postman which in general works pretty easily. However, I now want to access some of the data of the request, a query parameter to be exact. You can access the request URL through the "request.url" object which returns a String. Is there an easy way in Postman to parse this URL string to access the query parameter(s)?

推荐答案

如果您想提取 URL 编码格式的查询字符串而不对其进行解析.操作方法如下:

If you want to extract the query string in URL encoded format without parsing it. Here is how to do it:

pm.request.url.getQueryString() // example output: foo=1&bar=2&baz=3

这篇关于如何在 Postman 中获取请求参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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