[英]Postman: sending nested JSON object
我正在使用 ASP.NET Web API: http://xyzdomain.com:16845/api/returns/returns
如何使用 Postman Chrome 擴展向端點發送 POST 請求,給定Items
是一個集合:
[
{
"Items": [
{
"sku": "9257",
"Price": "100",
"Quantity": "500",
"DiscountPercent": "1",
"backordered": "2"
}
],
"order_id": "F429768865001",
"status_code": "Shelf",
"Exception": "no error"
}
]
將其作為原始數據發送並將類型設置為application/json
鍵值對可以采用高級輸入。
前任。
只需添加這些參數:在請求的標頭選項中,添加Content-Type:application/json
並在正文中,選擇原始格式並將您的 json 參數設置為{'guid':'61791957-81A3-4264-8F32-49BCFB4544D8'}
我在http://www.iminfo.in/post/post-json-postman-rest-client-chrome上找到了解決方案
只是想再添加一個問題,有些人可能會在所有其他答案之上找到這些問題。 如上所述,使用 RAW 數據發送 JSON 對象並將類型設置為application/json
。
即使我這樣做了,我還是在 POSTMAN 請求中出錯,這是因為我不小心忘記為兩個子類創建默認構造函數。
假設我必須發送格式的 JSON:
{
"firstname" : "John",
"lastname" : "Doe",
"book":{
"name":"Some Book",
"price":12.2
}
}
然后只需確保為 Book 類創建一個默認構造函數。
我知道這是一個簡單且不常見的錯誤,但確實對我有幫助。
僅適用於那些想要發送帶有表單數據作為內容類型的嵌套 JSON 對象的人。
我想在下面發送嵌套的 custom_field { "description": "Details about the issue...", "subject": "Support Needed...", "type": "Others", "email": "tom@outerspace.com", "priority": 1, "status": 2, **"custom_fields" : { "cf_type_of_issue" : "Complaint" }**, "cc_emails": ["ram@freshdesk.com","diana@freshdesk.com"] }
我們可以像以下格式一樣發送嵌套的json
地址[城市] 地址[州]
如果你想發布單個嵌套字典,可以說:
錯誤的:
{
parent_key: { child_key: child_value }
}
您需要將其轉換為:
正確的
{
parent_key.child_key: child_value
}
如果您想發布詞典列表,可以說:
錯誤的:
{
parent_key: [
{ child_key: child_value },
{ child_key: child_value_02 }
]
}
您需要將其轉換為:
正確的
{
parent_key[0]child_key: child_value
parent_key[1]child_key: child_value_02
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.