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

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

当前回答

转到Header,选择Content-Type = application/json,然后转到body,选择raw,然后传递一个数组。

其他回答

假设你有下面的对象数组,

features: [
      {
        title: { type: String },
        type: { type: String },
      },
    ],

要在邮差的表单数据上添加值,请按以下方式添加

features[title]
features[type]

看看下面的图片

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

如:

my_array:value_1
my_array:value_2

这是对我有用的方法

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

我认为这主要取决于后端是如何设置的。

选择form-data或urlencoded,并使用相同的键“user_ids”。服务器应该以数组的形式接收它。

在报头集中

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

在body中选择选项

x-www-form-urlencoded

并插入数据作为json数组

user_ids : ["1234", "5678"]