Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Setting Content Type as application/json

$
0
0

Hi!

In my WebApiConfig file, I have the following line so JSON is returned by default:

config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));

The problem is, the returned Content Type is then "text/html." That works, but it's messing up the resource trying to get the JSON as it's expecting the Content Type to be "application/json."

I tried changing the value to "application/json," but then it throws an Exception.

What am I doing wrong?

Thanks!

-Eric


Viewing all articles
Browse latest Browse all 4850

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>