Geeks With Blogs
Abhishek Anand Bits & Bytes about .net technology framework.
Have you seen this error message when making a call to a Web API Service Endpoint? 

No MediaTypeFormatter is available to read an object of type ‘' from content with media type 'text/html'. 

Unfortunately this is a very misleading error message and developers complain about it a good amount. Most of the time it means that some sort of error occurred during your Service call back to the Web API. The caller is expecting a response of type XML or JSON so it can deserialize it back into the response object, but some sort of error message is coming back instead. Since error messages come back as an HTML page to display to the user, or just plain text, the UI is confused about why it’s receiving HTML and not JSON/XML (thus the message). The root cause is back in the Service somewhere. 

To resolve this/figure out what the issue really is, either debug the service you are calling or open up Fiddler so you can see the HTML/Error Message that the service is returning.
Posted on Monday, November 18, 2013 1:02 PM .net | Back to top

Comments on this post: Media Type Formatter Exception

# re: Media Type Formatter Exception
Requesting Gravatar...
Thanks for this, saved me some grief as soon as I realized it wasn't an issue with the server side formatter
Left by Zach on Nov 15, 2014 9:45 PM

Your comment:
 (will show your gravatar)

Copyright © Abhishek Anand | Powered by: