Your Account object is null, because the C# code is inconsistent with JSON you provided. That's how MVC defends itself from badly formed requests.
Model suggests, that what you get in JSON are just these 2 pure fields, id and number, so JSON for it should look like this:
{
"id": "13456454",
"number": "222"
}
To make C# model adapted for provided JSON it should be built like this:
public class Accounts
{
public Account Accounts { get; set; }
}
public class Account
{
public string id { get; set; }
public string number { get; set; }
}
And API Action prototype should look like this:
public object Post([FromBody] Accounts account)
By this you contain Account into another class with property Accounts resembling what you have in provided JSON.
However your naming scheme suggest that single request might contain more than single account. To achieve this C# Classes should look like this:
public class Accounts
{
public Account[] Accounts { get; set; }
}
public class Account
{
public string id { get; set; }
public string number { get; set; }
}
And your JSON should contain object array:
{
"Accounts": [
{
"id": "13456454",
"number": "222",
},
{
"id": "23456",
"number": "125",
},
]
}
Of course that array can contain only single element, if you need so, but it will allow you to put more than one Account at once, as your naming suggests.
For future reference, you should be more precise at what you want to be the result, to make sure we know best how we should help you.
{ "id": "13456454", "number": "222", }Accountsfield, and it doesn't exist in C# model. You should either use{ "id": "13456454", "number": "222", }as data you are POSTing or add extra model, that will contain that simpler model, with field namedAccountsand type Account (not array of accounts, as name might suggest, because your JSON doesn't contain an array.