Question

ANONYMOUS WEB SERVICE FOR JSON POST

HI,

I've created a anonymous custom web service (rest endpoint) that should fetch the json body that was posted by the client (e.g postman):

 

Q: How can I get the json payload?   

 

[OperationContract]

[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]

public string PostPayload()

{

  // -- ??? ---

  // HOW CAN I FETCH THE JSON RAW BODY THAT WAE SENT ????

  //

   return "OK";

 

Thanks 

Eran Malik

Like 0

Like

1 comments

Hi Eran,

 

Something like this:

[OperationContract]
        [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,
        ResponseFormat = WebMessageFormat.Json)]
        public string GetInputNameFromServer(string Name){
			return Name + " returned from server";
        }

and the result is:

Best regards,

Oscar

Show all comments