Unsupported Media Type on ASP.Net Core 2.2 ApiController

谁都会走 提交于 2019-12-24 04:05:16

问题


I have the following controller and actions:

[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) {

  }

}

I tried to access both actions using Angular and Insomnia ...

I am able to access CreateByUserId [POST] but I get an error on GetByUserId [GET]:

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

What am I missing? The action is a simple Get action.

来源:https://stackoverflow.com/questions/55959728/unsupported-media-type-on-asp-net-core-2-2-apicontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!