Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

arrays

postman

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.

like image 330
Haniku Avatar asked Aug 23 '17 08:08

Haniku


People also ask

How do you send an array in Postman X-www-form-Urlencoded?

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.

How do you pass X-www-form-Urlencoded parameters in Postman?

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.

How do I use application X-www-form-Urlencoded?

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.

How do you send data in application X-www-form-Urlencoded in react?

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?


1 Answers

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.

like image 124
El Bayames Avatar answered Sep 18 '22 23:09

El Bayames