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
2 comments
16:50 Aug 08, 2022
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
Show all comments