I had successfully deserialized a simple json object but when I send an array of json object using a POST request to my controller, it fails. Here is my code:
[HttpPost]
public string addWwarehouse([FromBody] warehouse warehouses)
{
System.Diagnostics.Debug.WriteLine(warehouses[0].name);
return "success";
}
This is working json data:
{
"warehouses":
{
"name":"WarehouseA",
"location":"locationA"
}
}
But when I use an array like this,
[{
"warehouses":
{
"name":"WarehouseA",
"location":"locationA"
}
}]
It doesn't work. I also tried using List<warehouse>
but still no luck. This is my warehouse
class:
public class warehouse {
public string name { get; set; }
public string location { get; set; }
}