Access Request Body in a WCF RESTful Service

c#, http, rest, wcf

Solution

Best way i think doesn't involve WebOperationContext

[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "EntryPoint", BodyStyle = WebMessageBodyStyle.Bare)]
MyData GetData(System.IO.Stream pStream);

Problem

How do I access the HTTP POST request body in a WCF REST service? Here is the service definition: ``` [ServiceContract] public interface ITestService { [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "EntryPoint")] MyData GetData(); } ``` Here is the implementation: ``` public MyData GetData() { return new MyData(); } ``` I though of using the following code to access the HTTP request: ``` IncomingWebRequestContext context = WebOperationContext.Current.IncomingRequest; ``` But the IncomingWebRequestContext only gives access to the headers, not the body. Thanks.

Original source