I\'m new to web-api. I want to receive a HTTP POST data using web-api. The content-type is application/x-www-form-urlencoded
, and the request body is like:
You should create an object of your data like:
public class Device
{
public string mac {get;set;}
public string model {get;set;}
}
then change your controller's action method like this and pass your object to this method from consume
public void Post(Device deviceData)
{
// You can extract data like deviceData.mac, deviceData.model etc
data.Add(deviceData);
}
You can use one of the popular library json.net for serialize/deserialize of json object in C#