ASP.Net Core 2.2 ApiController上不受支持的媒体类型

时间:2019-05-02 20:22:43

标签: asp.net-core asp.net-core-2.2

我具有以下控制器和操作:

[ApiController, ApiVersion("1.0", Deprecated = false), Route("v{version:version}")]
public class PostController : ControllerBase {

  [HttpGet("users/{userId}/posts")]
  public async Task<IActionResult> GetByUserId(GetModel model) {

  }

  [HttpPost("users/{userId}/posts")]
  public async Task<IActionResult> CreateByUserId(CreateModel model) {

  }

}

我尝试使用Angular和Insomnia访问这两个动作...

我能够访问CreateByUserId [POST],但在GetByUserId [GET]上却收到错误消息:

{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.13",
  "title": "Unsupported Media Type",
  "status": 415,
  "traceId": "0HLMF7BM7U94L:00000001"
}

我想念什么?该动作是一个简单的Get动作。

0 个答案:

没有答案
相关问题