jim crown jim crown - 2 months ago 41
C# Question

Why I am getting a 415 response here?

I created the default Web API project using ASP.NET Core. That gave me following controller

public class ValuesController : Controller
// GET api/values
public IEnumerable<string> Get()
return new string[] { "value1", "value2" };

// GET api/values/5
public string Get(int id)
return "value";

// POST api/values
public void Post([FromBody]string value)

// PUT api/values/5
public void Put(int id, [FromBody]string value)

// DELETE api/values/5
public void Delete(int id)

I am using fiddler to test the api.

When I submit a GET request
I get a JSON object with value1 and value2 values

When I try a post to same URL, I get an unsupported media type 415 response as shown below.
Click here to see the image

What am I doing wrong?


Your request is forged wrong. There is no application\json mime-type.

The correct mime-type for JSON is application/json (notice the forward slash).


Also you're not allowed to have quotes in it. The final header needs to be: Content-Type: application/json