Is it possible to send an array with the Postman C

2019-01-04 05:19发布

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

16条回答
可以哭但决不认输i
2楼-- · 2019-01-04 05:57
{
    "data" : [  
        {
            "key1" : "value1",
            "key2" : "value2"   
        },
        {
            "key01" : "value01",
            "key02" : "value02"             
        },
        {
            "key10" : "value10",
            "key20" : "value20"   
        }
    ]
}

You can pass like this. Hope this will help someone.

查看更多
狗以群分
3楼-- · 2019-01-04 06:08

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

查看更多
别忘想泡老子
4楼-- · 2019-01-04 06:08

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 wen to raw json format and set the array:

["bbbbbbbbbb","aaaaaaaaaa","987654321","123456789"]
查看更多
冷血范
5楼-- · 2019-01-04 06:10

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"]
查看更多
我想做一个坏孩纸
6楼-- · 2019-01-04 06:12

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
查看更多
一夜七次
7楼-- · 2019-01-04 06:12

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

查看更多
登录 后发表回答