我一直在使用邮递员Chrome扩展来测试我的API,并想通过post发送一个id数组。有没有一种方法可以在Postman中将此作为参数发送?
{
user_ids: ["1234", "5678"]
}
我一直在使用邮递员Chrome扩展来测试我的API,并想通过post发送一个id数组。有没有一种方法可以在Postman中将此作为参数发送?
{
user_ids: ["1234", "5678"]
}
当前回答
我也遇到过这样的问题,并通过以下方法解决了它:
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"]
其他回答
正如@pinouchon提到的,你可以在数组索引的帮助下传递它
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
例子:
To pass param1=[{name:test_name, value:test_value}, {...}]
param1[0][name] test_name
param1[0][value] test_value
{
"data" : [
{
"key1" : "value1",
"key2" : "value2"
},
{
"key01" : "value01",
"key02" : "value02"
},
{
"key10" : "value10",
"key20" : "value20"
}
]
}
你可以这样通过。
假设你有下面的对象数组,
features: [
{
title: { type: String },
type: { type: String },
},
],
要在邮差的表单数据上添加值,请按以下方式添加
features[title]
features[type]
看看下面的图片
在我的例子中,我需要发送数组对象,我是这样发送的
选择form-data或urlencoded,并使用相同的键“user_ids”。服务器应该以数组的形式接收它。