Search code examples
asp.net-mvcpostasp.net-web-apifiddler

System.Net.Http.UnsupportedMediaTypeException exception occur in fiddler on running Web API post request in fiddler


I am new in ASP.NET MVC web api. I am trying to run default web api project created by visual studio 2013. Also, I am using fiddler to test web api.

In that default project a post method is created 'api/Account/Register'. When I try to run this in fiddler UnsupportedMediaTypeException occurs. I search a lot and tried adding content type content-type: application/json; header in fiddler's composer section. But exception still occurs. Following is the complete exception detail -

{"Message":"The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource.","ExceptionMessage":"No MediaTypeFormatter is available to read an object of type 'RegisterBindingModel' from content with media type 'application/octet-stream'.","ExceptionType":"System.Net.Http.UnsupportedMediaTypeException","StackTrace":" at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpContentExtensions.ReadAsAsync(HttpContent content, Type type, IEnumerable1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)\r\n at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger, CancellationToken cancellationToken)"}

Here is my setting in fiddler - enter image description here

enter image description here

please let me know what I am missing.


Solution

  • Try to insert an accept header:

    Accept: */*
    

    Meaning: Give what you have...

    Or

    Accept: application/json
    

    Meaning: Give me JSON