I want to send array using postman. the request looks like this:
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:
But its wrong because value ads is string not array.
You need to define array name as a “Key” and array elements as a “value”. This way you can post array using x-www-form-urlencoded.
If your API requires url-encoded data, select x-www-form-urlencoded in the Body tab of your request. Enter your key-value pairs to send with the request and Postman will encode them before sending.
To use it, we need to select the x-www-form-urlencoded tab in the body of their request. We need to enter the key-value pairs for sending the request body to the server, and Postman will encode the desired data before sending it. Postman encodes both the key and the value.
Show activity on this post. var obj = { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', }, }; fetch('https://example.com/login', obj) . then(function(res) { // Do stuff with result }); How can I include the form-encoded parameters in the request?
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"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With