Not sure about the reason but Removing lines charset=utf8
from con.setRequestProperty("Content-Type", "application/json; charset=utf8")
resolved the issue.
Add Content-Type
: application/json
and Accept
: application/json
If you are making jquery ajax request, dont forget to add
contentType:'application/json'
This is because charset=utf8
should be without a space after application/json
. That will work fine. Use it like application/json;charset=utf-8
If you are using AJAX
jQuery
Request this is a must to apply. If not it will throw you 415
Error.
dataType: "json",
contentType:'application/json'
If you get this in React RSAA middleware or similar, Add the headers:
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(model),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With