邮递员:发送嵌套的 JSON 对象
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26705782/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Postman: sending nested JSON object
提问by user3965303
I am using ASP.NET Web API: http://xyzdomain.com:16845/api/returns/returns
我正在使用 ASP.NET Web API:http: //xyzdomain.com: 16845/api/ returns/returns
How do I send a POST request to the endpoint using Postman Chrome extension, given Itemsis a collection:
如何使用 Postman Chrome 扩展程序向端点发送 POST 请求,给出Items一个集合:
[
{
"Items": [
{
"sku": "9257",
"Price": "100",
"Quantity": "500",
"DiscountPercent": "1",
"backordered": "2"
}
],
"order_id": "F429768865001",
"status_code": "Shelf",
"Exception": "no error"
}
]
回答by standup75
Send it as raw data and set the type to application/json
将其作为原始数据发送并将类型设置为 application/json


回答by Peyotle
回答by ImranNaqvi
回答by aefhm
The key-value pair can take advanced inputs.
键值对可以采用高级输入。
Ex.
前任。


回答by TBirkulosis
This is a combination of the above, because I had to read several posts to understand.
这是上面的组合,因为我必须阅读几篇文章才能理解。
- In the Headers, add the following key-values:
Content-Typetoapplication/json- and
Accepttoapplication/json
- 在Headers 中,添加以下键值:
Content-Type到application/json- 并
Accept以application/json
- In the Body:
- change the type to "raw"
- confirm "JSON (application/json)" is the text type
- put the nested property there:
{ "Obj1" : { "key1" : "val1" } }
- 在身体:
- 将类型更改为“原始”
- 确认“JSON (application/json)”是文本类型
- 将嵌套属性放在那里:
{ "Obj1" : { "key1" : "val1" } }
Hope this helps!
希望这可以帮助!
回答by Ema.H
Simply add these parameters :
In the headeroption of the request, add Content-Type:application/json
只需添加这些参数:在请求的header选项中,添加Content-Type:application/json
and in the body, select Rawformat and put your json params like {'guid':'61791957-81A3-4264-8F32-49BCFB4544D8'}
并在正文中,选择原始格式并将您的 json 参数设置为{'guid':'61791957-81A3-4264-8F32-49BCFB4544D8'}
I've found the solution on http://www.iminfo.in/post/post-json-postman-rest-client-chrome
我在http://www.iminfo.in/post/post-json-postman-rest-client-chrome上找到了解决方案
回答by bhanushrestha
Just wanted to add one more problem that some people might find on top of all the other answers. Sending JSON object using RAW data and setting the type to application/jsonis what is to be done as has been mentioned above.
只是想再添加一个问题,有些人可能会在所有其他答案之上找到这些问题。使用 RAW 数据发送 JSON 对象并将类型设置application/json为如上所述。
Even though I had done so, I got error in the POSTMAN request, it was because I accidentally forgot to create a default constructor for both child class.
即使我这样做了,我还是在 POSTMAN 请求中出错,这是因为我不小心忘记为两个子类创建默认构造函数。
Say if I had to send a JSON of format:
假设我必须发送格式的 JSON:
{
"firstname" : "John",
"lastname" : "Doe",
"book":{
"name":"Some Book",
"price":12.2
}
}
Then just make sure you create a default constructor for Book class.
然后只需确保为 Book 类创建一个默认构造函数。
I know this is a simple and uncommon error, but did certainly help me.
我知道这是一个简单且不常见的错误,但确实对我有帮助。
回答by Suraj Kshirsagar
回答by techyaura
Best way to do that:
最好的方法是:
In the Headers, add the following key-values:
Content-Type to applications/json Accept to applications/jsonUnder body, click
rawand dropdown type toapplication/json
在标题中,添加以下键值:
Content-Type to applications/json Accept to applications/json在正文下,单击
raw并下拉类型以application/json
Also PFA for the same
同样的 PFA

