Is it possible to send an array with the Postman Chrome extension?

Google ChromeRestPost

Google Chrome Problem Overview


I've been using Postman Chrome extension to test out my API and would like to send an array of IDs via post. Is there a way to send something list this as a parameter in Postman?

{
  user_ids: ["1234", "5678"]
}

Google Chrome Solutions


Solution 1 - Google Chrome

You need to suffix your variable name with [] like this:

send_array_param_with_postman

If that doesn't work, try not putting indexes in brackets:

my_array[]  value1
my_array[]  value2

Note:

  • If you are using the postman packaged app, you can send an array by selecting raw / json (instead of form-data). Also, make sure to set Content-Type as application/json in Headers tab. Here is example for raw data {"user_ids": ["123" "233"]}, don't forget the quotes!

  • If you are using the postman REST client you have to use the method I described above because passing data as raw (json) won't work. There is a bug in the postman REST client (At least I get the bug when I use 0.8.4.6).

Solution 2 - Google Chrome

For me did not work with array[0], array1, .. or array[], array[], ... . It works more simply: enter image description here

Solution 3 - Google Chrome

Here is my solution:

use form-data and edit as below:

Key       Value 
box[]      a
box[n1]    b
box[n2][]  c
box[n2][]  d

and you will get an array like this:

{"box":{"0":"a","n1":"b","n2":["c","d"]}}

Solution 4 - Google Chrome

If you want an array of dicts, try this: enter image description here

Solution 5 - Google Chrome

I also had that problem, and solved it by doing the following:

1 - Going to the request header configuration and added the following:

Accept : application/json, text/plain, */*
Content-Type : application/json;charset=UTF-8

2 - To send the json array, I went to raw json format and set the user_ids to array:

user_ids: ["bbbbbbbbbb","aaaaaaaaaa","987654321","123456789"]

Solution 6 - Google Chrome

It is important to know, that the VALUE box is only allowed to contain a numeral value (no specifiers).

If you want to send e.g. an array of "messages" with Postman, each having a list of key/value pairs, enter e.g. messages[][reason] into the KEY box and the value of reason into the VALUE box:

enter image description here

The server will receive:

{"messages"=>[{"reason"=>"scrolled", "tabid"=>"2"}, {"reason"=>"reload", "tabid"=>"1"}], "endpoint"=>{}}

Solution 7 - Google Chrome

Set Body as raw and form the array as follows:

enter image description here

Solution 8 - Google Chrome

As mentioned by @pinouchon you can pass it with the help of array index

my_array[0] value
my_array[1] value

In addition to this, to pass list of hashes, you can follow something like:

my_array[0][key1] value1

my_array[0][key2] value2

Example:

To pass param1=[{name:test_name, value:test_value}, {...}]

param1[0][name] test_name

param1[0][value] test_value

Solution 9 - Google Chrome

Go to Header and select Content-Type = application/json then go to body and select raw and then pass an array.enter image description here

Solution 10 - Google Chrome

this worked for me. to pass an array of Item object {ItemID,ColorID,SizeID,Quntity}

Postman data

Solution 11 - Google Chrome

in headers set

content-type : application/x-www-form-urlencoded

In body select option

> x-www-form-urlencoded

and insert data as json array

user_ids : ["1234", "5678"]

Solution 12 - Google Chrome

This also works for lists within the object:

Id:37
IdParent:26
Name:Poplet
Values[0].Id:1349
Values[0].Name:SomeName
Values[1].Id:1350
Values[1].Name:AnotherName

the equivalent JSON would be:

{
    "Id": 37,
    "IdParent": 26,
    "Name": "Poplet",
    "Values": [
        {
            "Id": 1349,
            "Name": "SomeName"
        },
        {
            "Id": 1350,
            "Name": "AnotherName"
        }
    ]
}

Solution 13 - Google Chrome

{
	"data" : [	
		{
			"key1" : "value1",
            "key2" : "value2"   
		},
		{
			"key01" : "value01",
            "key02" : "value02"   			
		},
		{
			"key10" : "value10",
            "key20" : "value20"   
		}
	]
}

You can pass like this.

Solution 14 - Google Chrome

Choose either form-data or urlencoded and use the same key "user_ids". The server should receive it as an array.

Solution 15 - Google Chrome

In form-data,

   key              value

 user_ids[]         1234
 user_ids[]         5678

Solution 16 - Google Chrome

My back-end is written in Ruby on Rails. This is how I sent the array params using Postman. It worked for me.

UPDATE

I'm using x-www-form-urlencoded. I believe it will work too for form-data.

enter image description here

Solution 17 - Google Chrome

In form-data you can pass a array like this

enter image description here

and in backend you will fetch it like a

"tags"=>["aaaa", "bbb"]

In my case I've to pass two values in a array so I write it two times

Solution 18 - Google Chrome

I tried all solution here and in other posts, but nothing helped.

The only answer helped me:
Adding [FromBody] attribute before decleration of parameter in function signature:

[Route("MyFunc")]        
public string MyFunc([FromBody] string[] obj)

Solution 19 - Google Chrome

Supposing you have the array of object below,

features: [
      {
        title: { type: String },
        type: { type: String },
      },
    ],

To add the values on the form data on the postman, add it this way

features[title]
features[type]

Check also the image below

enter image description here

Solution 20 - Google Chrome

Here is something that worked for me

{
 "user_ids":["[1234, 5678]"]
}

I believe it depends on how the backend is setup most of the time.

Solution 21 - Google Chrome

N.B Now we are in 2022 if All of the above solutions didn't, just don't panic. pass array name with is value without a bracket and the add it multiple time, just link how the image below is showing. it should work just fine. If It does work, buy me some coffee, hhh

enter image description here

Solution 22 - Google Chrome

The accepted question did not work for me.

To send an array using form data there's no need to use brackets. Just send that specific array using the same name in multiple fields.

Like:

my_array:value_1
my_array:value_2

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
QuestionWill HitchcockView Question on Stackoverflow
Solution 1 - Google ChromeBenjamin CrouzierView Answer on Stackoverflow
Solution 2 - Google ChromePopa AndreiView Answer on Stackoverflow
Solution 3 - Google ChromeGaryView Answer on Stackoverflow
Solution 4 - Google ChromeC.K.View Answer on Stackoverflow
Solution 5 - Google ChromemestevesView Answer on Stackoverflow
Solution 6 - Google ChromeAlexander RoehnischView Answer on Stackoverflow
Solution 7 - Google ChromedanywarnerView Answer on Stackoverflow
Solution 8 - Google ChromeManojView Answer on Stackoverflow
Solution 9 - Google ChromeFarhanView Answer on Stackoverflow
Solution 10 - Google ChromeAbdu ImamView Answer on Stackoverflow
Solution 11 - Google ChromeArisView Answer on Stackoverflow
Solution 12 - Google ChromeonicofagoView Answer on Stackoverflow
Solution 13 - Google ChromeNarendra SolankiView Answer on Stackoverflow
Solution 14 - Google ChromeAbhinavView Answer on Stackoverflow
Solution 15 - Google ChromeMritunjay UpadhyayView Answer on Stackoverflow
Solution 16 - Google ChromeZulhilmi ZainudinView Answer on Stackoverflow
Solution 17 - Google Chromemanish nautiyalView Answer on Stackoverflow
Solution 18 - Google ChromeRachel FishbeinView Answer on Stackoverflow
Solution 19 - Google ChromeSunday ArohView Answer on Stackoverflow
Solution 20 - Google ChromeDaniel ChettiarView Answer on Stackoverflow
Solution 21 - Google ChromeNdatimana GilbertView Answer on Stackoverflow
Solution 22 - Google ChromeAli NowrouziView Answer on Stackoverflow