我在asp.net中进行了操作,得到了一个包含12个属性的json。它们是数组类型。当我发回POST时,它返回错误400(错误请求)。调试代码直到类独立注入并且已经返回错误为止。
搜索我发现您可能是我正在发送的json和Controller方法接收到的MODEL
我的控制器
[HttpPost]
[ProducesResponseType(typeof(Guid), (int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
[ProducesResponseType((int)HttpStatusCode.Forbidden)]
public async Task<IActionResult> Add(Employee address)
{
}
public class Employee
{
[BsonId]
public Guid ownerId { get; set; }
[BsonElement("personalData")]
public PersonalData personalData { get; set;}
[BsonElement("address")]
public Address address { get; set; }
[BsonElement("emails")]
public Emails emails { get; set; }
[BsonElement("syndicate")]
public Syndicate syndicate { get; set; }
[BsonElement("dependents")]
public Dependents dependents { get; set; }
[BsonElement("phone")]
public Phone phone { get; set; }
[BsonElement("bank")]
public Bank bank { get; set; }
[BsonElement("attributes")]
public Attributes attributes { get; set; }
[BsonElement("benefits")]
public Benefits benefits { get; set; }
[BsonElement("transport")]
public Transport transport { get; set; }
[BsonElement("attachments")]
public Attachments attachments {get; set; }
[BsonElement("documents")]
public Documents documents { get; set; }
}
我有一些疑问,PersonalData,Address模型必须具有
[BsonElement(“”)]
如何获取带有数组的json映射到这些人? 有什么我可以看的材料吗?