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 .
If you're creating an array, then you could use the pm. globals. get("variable_key") to set the respective elements in your array.
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:
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:
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:
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:
The server will receive:
{"messages"=>[{"reason"=>"scrolled", "tabid"=>"2"}, {"reason"=>"reload", "tabid"=>"1"}], "endpoint"=>{}}
Set Body as raw and form the array as follows:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With