我正在使用带有属性路由的 ASP.NET Web API 2。
我有以下PlayerModel
。
public class PlayerModel
{
public int Id { get; set; }
public string Key { get; set; }
public string Name { get; set; }
public string Password { get; set; }
public int TeamId { get; set; }
public PlayerStatModel Stat{ get; set; }
}
public class PlayerStatModel
{
public int PlayerId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Title { get; set; }
public string EmailAddress { get; set; }
public IEnumerable<PhoneNumberModel> PhoneNumbers { get; set; }
public int TeamId { get; set; }
}
public class PhoneNumberModel
{
public string Value { get; set; }
public string Extension { get; set; }
}
依次传递PostPlayer
给玩家创建。
[HttpPost("", RouteName = "PostPlayer")]
public PlayerModel PostPlayer(PlayerModel player)
{
var playerObject = this.GetObject(player));
this._manager.CreatePlayer(playerObject );
return this.GetPlayer(playerObject.Id);
}
我的集成测试通过了,我能够验证播放器在CreatePlayer
被调用时确实是创建的。
如何POST
在 Google Chrome 的 POSTMAN Rest Client 中建模此请求?