问题
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