Question

Custom Endpoint using WebInvoke form-data

Hello all, I have and custom end point that works great with JSON and XML. I need one to accept form-data. But I get this error:

The server encountered an error processing the request. The exception message is 'The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'. This can       be because a WebContentTypeMapper has not been configured on the binding.

I am testing locally but am building for the cloud. Any suggestions?

 

Thank you

Like 0

Like

2 comments

Hi Keith



You can use the following sample code to get the request body as a stream, then parse it and do your business logic.

[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json)]
public void Submit(Stream data)
{
	var sr = new StreamReader(data);
	var content = sr.ReadToEnd();
 
	WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
}

 

Thank you

Mohamed

This is great, thank you very much

Show all comments