Postman: sending nested JSON object

JsonGoogle Chromeasp.net Web-ApiPostman

Json Problem Overview


I am using 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 Items is a collection:

[  {    "Items": [      {        "sku": "9257",        "Price": "100",        "Quantity": "500",        "DiscountPercent": "1",        "backordered": "2"      }    ],
    "order_id": "F429768865001",
    "status_code": "Shelf",
    "Exception": "no error"
  }
]

Json Solutions


Solution 1 - Json

Send it as raw data and set the type to application/json

enter image description here

Solution 2 - Json

To post a nested object with the key-value interface you can use a similar method to sending arrays. Pass an object key in square brackets after the object index.

Passing a nested item with Postman

"Items": [
      {
        "sku": "9257",
        "Price": "100"
      }
 ]

Solution 3 - Json

I got it working using the Raw data option in postman, as you can see in the screen shot

enter image description here

Solution 4 - Json

This is a combination of the above, because I had to read several posts to understand.

  1. In the Headers, add the following key-values:
  2. Content-Type to application/json
  3. and Accept to application/json

enter image description here

  1. In the Body:
  2. change the type to "raw"
  3. confirm "JSON (application/json)" is the text type
  4. put the nested property there: { "Obj1" : { "key1" : "val1" } }

enter image description here

Hope this helps!

Solution 5 - Json

The key-value pair can take advanced inputs.

Ex.

enter image description here

Solution 6 - Json

Simply add these parameters : In the header option of the request, add Content-Type:application/json

header content-type postman json

and in the body, select Raw format and put your json params like {'guid':'61791957-81A3-4264-8F32-49BCFB4544D8'}

json request postman

I've found the solution on http://www.iminfo.in/post/post-json-postman-rest-client-chrome

Solution 7 - Json

Select the body tab and select application/json in the Content-Type drop-down and add a body like this:

{
  "Username":"ABC",
  "Password":"ABC"
}

enter image description here

Solution 8 - Json

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/json is what is to be done as has been mentioned above.

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.

Say if I had to send a JSON of format:

{
 "firstname" : "John",
 "lastname" : "Doe",
 "book":{
   "name":"Some Book",
   "price":12.2
  }
}

Then just make sure you create a default constructor for Book class.

I know this is a simple and uncommon error, but did certainly help me.

Solution 9 - Json

Best way to do that:

  1. In the Headers, add the following key-values:

     Content-Type to applications/json
     Accept to applications/json
    
  2. Under body, click raw and dropdown type to application/json

Also PFA for the same

enter image description here

enter image description here

Solution 10 - Json

For a nested Json(example below), you can form a query using postman as shown below.

{
	"Items": {
		"sku": "10 Units",
		"Price": "20 Rs"
	},
	"Characteristics": {
		"color": "blue",
		"weight": "2 lb"
	}
}

enter image description here

Solution 11 - Json

Just for those who want to send a nested JSON object with form-data as content type.

I want to send nested custom_field in below { "description": "Details about the issue...", "subject": "Support Needed...", "type": "Others", "email": "[email protected]", "priority": 1, "status": 2, **"custom_fields" : { "cf_type_of_issue" : "Complaint" }**, "cc_emails": ["[email protected]","[email protected]"] }

enter image description here

Solution 12 - Json

We can send nested JSON like the following format

address[city]
address[state]

Solution 13 - Json

In the Params I have added model.Email and model.Password, work for me well. Thanks for the question. I tried the same thing in headers did not work. But it worked on Body with form-data and x-www-form-urlencoded.

Postman version 6.4.4

enter image description here

Solution 14 - Json

If you want to send it as key-value Query Param via GET, you can paste your json in the inputtext as value, and then select this text, right click on it and click "EncodeUriComponent":

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3965303View Question on Stackoverflow
Solution 1 - Jsonstandup75View Answer on Stackoverflow
Solution 2 - JsonPeyotleView Answer on Stackoverflow
Solution 3 - JsonManiView Answer on Stackoverflow
Solution 4 - JsonTBirkulosisView Answer on Stackoverflow
Solution 5 - JsonaefhmView Answer on Stackoverflow
Solution 6 - JsonEma.HView Answer on Stackoverflow
Solution 7 - JsonSuraj KshirsagarView Answer on Stackoverflow
Solution 8 - JsonbhanushresthaView Answer on Stackoverflow
Solution 9 - JsonAbhayView Answer on Stackoverflow
Solution 10 - JsonArpanView Answer on Stackoverflow
Solution 11 - JsonMuhammad MaqsoodView Answer on Stackoverflow
Solution 12 - JsonAtchutha rama reddy KarriView Answer on Stackoverflow
Solution 13 - JsonKapila PereraView Answer on Stackoverflow
Solution 14 - JsonVikcenView Answer on Stackoverflow