简体   繁体   English

如何在邮递员的 URL 中传递正文参数?

[英]how to pass body parameters in URL in postman?

I am trying to pass raw body data in the POSTMAN URL section.我正在尝试在 POSTMAN URL 部分传递原始正文数据。 how I can achieve this?我怎么能做到这一点? have a look here: I have this URL in postman with the "GET" method http://localhost:8888/wordpress/wp-json/gh/v3/contacts and I am passing this data in the body看看这里:我在邮递员中有这个 URL,使用“GET”方法http://localhost:8888/wordpress/wp-json/gh/v3/contacts并且我正在将这些数据传递到正文中

{
"query":{
"tags_include" : 92
}
}

i have to pass id(92) in the URL of POSTMAN how can i do this?我必须在 POSTMAN 的 URL 中传递 id(92) 我该怎么做?

It can be done simply by passing parameters just in URL:只需在 URL 中传递参数即可完成:

http://localhost:8888/wordpress/wp-json/gh/v3/contacts?tags_include=92 http://localhost:8888/wordpress/wp-json/gh/v3/contacts?tags_include=92

Follow as per below screenshot按照下面的截图

在此处输入图片说明

localhost:8888/wordpress/wp-json/gh/v3/contacts/:{{tags_include}}本地主机:8888/wordpress/wp-json/gh/v3/contacts/:{{tags_include}}

If I have understood correctly, you are getting the raw data from some other URL and now you want to pass its "tags_include" parameter value in the URL specified above.如果我理解正确,您是从其他某个 URL 获取原始数据,现在您想在上面指定的 URL 中传递其“tags_include”参数值。

What you need to do is, use the above URL(that I edited) but, for it to work, you need to write the following code in the tests section of postman.您需要做的是,使用上面的 URL(我编辑过的),但是,要使其正常工作,您需要在 postman 的测试部分编写以下代码。 Use this code in the test section of the request that responds with the data(that you specified above).在使用数据(您在上面指定的)响应的请求的测试部分中使用此代码。

Here is the code:这是代码:

var body = JSON.parse(response body); var body = JSON.parse(响应体); postman.setEnvironmentVariable('tags_include', body.query.tags_include); postman.setEnvironmentVariable('tags_include', body.query.tags_include);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM