Send array as part of x-www-form-urlencoded

Hanka picture Hanka · Aug 23, 2017 · Viewed 32.4k times · Source

I want to send array using postman. the request looks like this: enter image description here

Im using postman to execute requests. I found on the internet to send array via form-data or raw. But I need them to be send as x-www-form-urlencoded. I tried it this way: enter image description here

But its wrong because value ads is string not array.

Answer

El Bayames picture El Bayames · Dec 20, 2018

I had a bit of a more complex objects. A class emaillist

public class emailist
{
    public String id { get; set; }
    public String emailaddress { get; set; }
    public String name { get; set; }
}   

A class emailRecipientList

public class emailRecipientList
{
    public String procedure { get; set; }
    public String server { get; set; }
    public String filename { get; set; }
    public String fileid { get; set; }
    public List<emailist> emaillists { get; set; }

}

And a Task

public async Task<System.Xml.XmlElement> postUploadEmailRecipientList([FromBody] emailRecipientList recipientList)

Now to send the data as "application/x-www-form-urlencoded" enter image description here

If more elements need to get added just keep increasing the array index. I tested it on a asp.net WebAPI 2 project and worked fine.