[json] Postman: sending nested JSON object

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"
  }
]

This question is related to json google-chrome asp.net-web-api postman

The answer is


The key-value pair can take advanced inputs.

Ex.

enter image description here


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


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


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


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:
    1. Content-Type to application/json
    2. and Accept to application/json

enter image description here

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

enter image description here

Hope this helps!


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

enter image description here


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"
      }
 ]

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


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


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.


we can send nested json like the following format

address[city] address[state]


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

enter image description here


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


Examples related to json

Use NSInteger as array index Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) HTTP POST with Json on Body - Flutter/Dart Importing json file in TypeScript json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 190) Angular 5 Service to read local .json file How to import JSON File into a TypeScript file? Use Async/Await with Axios in React.js Uncaught SyntaxError: Unexpected token u in JSON at position 0 how to remove json object key and value.?

Examples related to google-chrome

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81 SameSite warning Chrome 77 What's the net::ERR_HTTP2_PROTOCOL_ERROR about? session not created: This version of ChromeDriver only supports Chrome version 74 error with ChromeDriver Chrome using Selenium Jupyter Notebook not saving: '_xsrf' argument missing from post How to fix 'Unchecked runtime.lastError: The message port closed before a response was received' chrome issue? Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser How to make audio autoplay on chrome How to handle "Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first." on Desktop with Chrome 66?

Examples related to asp.net-web-api

Entity Framework Core: A second operation started on this context before a previous operation completed FromBody string parameter is giving null How to read request body in an asp.net core webapi controller? JWT authentication for ASP.NET Web API Token based authentication in Web API without any user interface Web API optional parameters How do I get the raw request body from the Request.Content object using .net 4 api endpoint How to use a client certificate to authenticate and authorize in a Web API HTTP 415 unsupported media type error when calling Web API 2 endpoint The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider" could not be located

Examples related to postman

Converting a POSTMAN request to Curl "Could not get any response" response when using postman with subdomain How do I format {{$timestamp}} as MM/DD/YYYY in Postman? How do I POST XML data to a webservice with Postman? How to send Basic Auth with axios How to install/start Postman native v4.10.3 on Ubuntu 16.04 LTS 64-bit? Websocket connections with Postman FromBody string parameter is giving null "Post Image data using POSTMAN" How to import Swagger APIs into Postman?