Postman输入List参数

使用Postman测试 一个API,有一个输入参数是List,查了半天,终于知道怎么输入了。

原帖子:http://stackoverflow.com/questions/12756688/is-it-possible-to-send-an-array-with-the-postman-chrome-extension

因为不同的postman版本好像输入方法不同,所以挨着试试看下面的方法。

如果要输入一个arrayList,arr={111,222};

方法1  把list元素分个写

参数名   参数值

 arr[0]    111

arr[1]      222

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

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

  • Just in case someone is asking how to add hashes instead of just array, the idea is still the same, just change the indexes to hash name my_array[hashname] value1

  • my_array[] 123, 345, 456 works fine

  • my_array[] value will create a array parameter with the values provided, as key => [value].my_array[key] value will create a hash, as {key => value}.

方法2 

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"]}}
方法3



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值