Click here to Skip to main content
15,885,910 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is working fine.
C#
public IHttpActionResult Post(Categories categories)
{
//...
}

But When I change Categories to Categories[] to received multiple records from javascript client, it show null object.

C#
public IHttpActionResult Post(Categories[] categories)
{
//...
}


from postman I've tried

post: {url}/odata/Categories
content-Type: application/json
body:
[
{ id: 1, Category: 'Value1' },
{ id: 2, Category: 'Value2' }
]

But I receive Null object at server side.

What I have tried:

I've also tried

{ id: 1, Category: 'Value1' },
{ id: 2, Category: 'Value2' }
Posted
Updated 30-Nov-19 17:39pm

1 solution

create another class contains list of Categories
public class CategoriesList 
{
IList<Categories> ListItem;
}
public IHttpActionResult Post(CategoriesList categories)
{
//...
}


body may something like this:
ListItem : [
{ id: 1, Category: 'Value1' },
{ id: 2, Category: 'Value2' }
]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900