Rest – Fiddler POST Invalid Header Name

fiddlerrestwcf

I am sending a POST request to a WCF Web service using fiddler, and the service responds with HTTP 400: The request has an invalid header name.
The post request looks like this:

User-Agent: Fiddler
Host: localhost:49392
Content-Type: application/json
Content-Length: 0
{  "clientFirstName" : "John"}

My endpoint is defined as follows:

 [OperationContract]
 [System.ServiceModel.Web.WebInvoke
       (Method = "POST",
       RequestFormat = WebMessageFormat.Json,
       ResponseFormat = System.ServiceModel.Web.WebMessageFormat.Json,
       BodyStyle = System.ServiceModel.Web.WebMessageBodyStyle.Wrapped,
       UriTemplate = "MakeReservation")]
 String MakeReservation(Stream reservationStream);

MORE

First of all, the JSON was in the wrong pane. I moved it to the Request Body pane.

I changed the prototype of the function to take a String instead of Stream as the input parameter. The service now accepts my call and returns 200, but in the debugger I see that the input parameter String is null. When I change it back to Stream, I get 400 again.

YET MORE

Enable tracing gives me at trace file with the following message:

Incoming message for operation 'MakeReservation' (contract 'ITalLimoService' with namespace 
'http://tempuri.org/') contains an unrecognized http body format value 'Json'. The expected body 
format value is 'Raw'. This can be because a WebContentTypeMapper has not been configured on the 
binding. See the documentation of WebContentTypeMapper for more details.

As noted int the WebInvoke definitiuon, both the RequestFormat and ResponseFormat are set to WebMessageFormate.Json. Why is IIS complaining about this?

Best Answer

I don't know why this works, but for some reason removing the following line from the fiddler Composer did the trick:

Content-Type: application/json

And that is that. I would give points for an explanation.

Related Topic