Only one value can come from the body.
Suppose you have a request body like this.
{"Id":12345, "FirstName":"John", "LastName":"West"}
You want this JSON to be bound to a type parameter like this.
public class Employee { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } }
The action method can be like a void Post(Employee emp) . And it can't be like that - void Post(Employee john, Employee duplicateJohn) . Only one value can come out of the body.
, and this value should represent the integrity of the body
Suppose you have the same request object as this one.
{"Id":12345, "FirstName":"John", "LastName":"West"}
And you have two DTOs like this.
public class Identifier { public int Id { get; set; } } public class Name { public string FirstName { get; set; } public string LastName { get; set; } }
You cannot have an action method such as void Post(Identifier id, Name name) , and expect the body to be partially bound to both parameters. The whole body should only be tied to the value of one . So, having a class like
public class Employee { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } }
and binding the request body as a whole to a single value, for example void Post(Employee emp) , is allowed only.