WCF Rest: WebInvoke Post variable is always null RRS feed

  • Question

  • Hello,

    I'm having a problem where my single parameter in my Rest service function is always sent a null value, no matter what I pass it.  We're using POST because the content of the data can be a fairly long Json string.  

    The WCF Rest service needs to interface with the following HTML page as an example.  

    <form action="http://<uri>/UpdateData" method="post">
    Data: <input type="text" id="data" name="data" value="[]"><br>
    <input type="submit" value="Submit">

    Service function is defined as follows:

            [WebInvoke(Method = "POST", 
              UriTemplate = "UpdateData?data={data}", 
              BodyStyle = WebMessageBodyStyle.Bare, 
              RequestFormat = WebMessageFormat.Json)]
            void UpdateData(string data);

    The web page posts the data without issue, but the value of the data in the function call is always null, no matter what is sent.  Any ideas?  Thanks in advance,

    John Marklund

    Wednesday, July 2, 2014 2:24 PM