我一直在使用邮递员Chrome扩展来测试我的API,并想通过post发送一个id数组。有没有一种方法可以在Postman中将此作为参数发送?

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

当前回答

要使用表单数据发送数组,不需要使用括号。 只需要在多个字段中使用相同的名称发送特定的数组。

如:

my_array:value_1
my_array:value_2

其他回答

重要的是要知道,VALUE框只允许包含一个数值(不允许包含说明符)。

如果你想通过Postman发送一个“消息”数组,每个“消息”都有一个键/值对列表,在key框中输入messages[][reason],在value框中输入reason的值:

服务器将收到:

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

在报头集中

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

在body中选择选项

x-www-form-urlencoded

并插入数据作为json数组

user_ids : ["1234", "5678"]

以下是我的解决方案:

使用form-data并按如下方式编辑:

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

你会得到一个这样的数组:

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

如果你想要一个字典数组,试试这个:

我也遇到过这样的问题,并通过以下方法解决了它:

1 -进入请求头配置并添加以下内容:

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

2 -为了发送json数组,我使用原始json格式,并将user_ids设置为array:

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