Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

Is it possible to send an array with the postman?

In form-data you can pass a array like this The server should receive it as an array. Looks like, due to a bug in Chrome that erroneously sends with an XML header even when you select JSON in Postman, you have to add a Content-type header with value application/json .

How do you set an array as a global variable in Postman?

If you're creating an array, then you could use the pm. globals. get("variable_key") to set the respective elements in your array.

How do you pass multiple parameters in Postman body?

Enter the same URL in the Postman text field; you will get the multiple parameters in the Params tab. Even you can write each of the parameters and send a request with multiple parameters.


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).


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


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

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


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

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"=>{}}

Set Body as raw and form the array as follows:

enter image description here