maxisam
maxisam

Reputation: 22735

Get 415 error when using AddMvcCore for webapi

Everything works fine when using AddMvc for webapi call, but it throws 415 back when using AddMvcCore.

request header is set as

Content-Type: application/json; charset=UTF-8 Accept: application/json

Any thought ?

Upvotes: 2

Views: 1670

Answers (1)

maxisam
maxisam

Reputation: 22735

It turns out I just need to add one more line

services.AddMvcCore() .AddJsonFormatters()

I think it is because the Web API was like

public string Post([FromBody] JObject arg)

It requires json.net to convert the json string.

Related discussion is here

Upvotes: 3

Related Questions