View Answer

I used to face this issue if the header 'Content-Type': 'application/json' is not added. Also refer POST JSON fails with 415 Unsupported media type, Spring 3 mvc, around the same lines.

Score: 7
Comments: 1
Date posted: 3/12/2013

View Answer

It was because there was no accept header sent with the request. You need to send a Accepts and Content-Type headers with the client code.

Since your application accepted json, It should be

<code>'Accept': 'application/json'</code>
<code>'Content-Type': 'application/json'</code>

Similar posting in SO Http 415 Unsupported Media type error with JSON, Error 415 Unsupported Media Type: POST not reaching REST if JSON, but it does if XML

Score: 1
Comments: 2
Date posted: 4/17/2016

View Answer

Check out some possible reasons here: http://javahonk.com/415-unsupported-media-type/

Score: 0
Comments: 0
Date posted: 4/1/2019

View Answer

In my case, I received the HTTP 415 Unsupported Media Type response, since I specified the content type to be TEXT and NOT JSON, so simply changing the type solved the issue. Please check the solution in more detail in the following blog post: https://www.howtodevelop.net/article/20/unsupported-media-type-415-in-aspnet-core-web-api

Score: 0
Comments: 0
Date posted: 1/22/2021

View Answer

use formdata.append('file', JSON.stringify(file));

please visit: POST JSON fails with 415 Unsupported media type, Spring 3 mvc

Score: 0
Comments: 0
Date posted: 2/25/2019


1


© 2021 Search Overflow
Contributions licensed under cc by-sa