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条回答
Fickle 薄情
2楼-- · 2019-01-04 06:12

I tried all solution here and in other posts, but nothing helped.

The only answer helped me:
Adding [FromBody] attribute before decleration of parameter in function signature:

[Route("MyFunc")]        
public string MyFunc([FromBody] string[] obj)
查看更多
叛逆
3楼-- · 2019-01-04 06:14

This also works for lists within the object:

Id:37
IdParent:26
Name:Poplet
Values[0].Id:1349
Values[0].Name:SomeName
Values[1].Id:1350
Values[1].Name:AnotherName

the equivalent JSON would be:

{
    "Id": 37,
    "IdParent": 26,
    "Name": "Poplet",
    "Values": [
        {
            "Id": 1349,
            "Nombre": "SomeName"
        },
        {
            "Id": 1350,
            "Nombre": "AnotherName"
        }
    ]
}
查看更多
我只想做你的唯一
4楼-- · 2019-01-04 06:14

In form-data,

   key              value

 user_ids[]         1234
 user_ids[]         5678
查看更多
等我变得足够好
5楼-- · 2019-01-04 06:14

Go to Header and select Content-Type = application/json then go to body and select raw and then pass an array.enter image description here

查看更多
成全新的幸福
6楼-- · 2019-01-04 06:15

For me did not work with array[0], array1, .. or array[], array[], ... . It works more simply: enter image description here

查看更多
走好不送
7楼-- · 2019-01-04 06:18

Choose either form-data or urlencoded and use the same key "user_ids". The server should receive it as an array.

查看更多
登录 后发表回答