Pass multiple parameters to RESTful service RRS feed


All replies

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 12, 2013 9:48 AM
  • User2043281626 posted

    Hmmm...perhaps I am missing something. But the example provided does not say that you can all the service as follows:


    The parameters passed need to be contained within one parameter being passed to the service, but the issue is that it is complaining about '&'.

    Monday, August 12, 2013 10:44 AM
  • User2043281626 posted

    I should mention that the reason the call must be made as specified is because we do own the application which will be calling the service, and are thus limited on how much impact in regards to change we can make. Ideally, we want the service call to be as specified above, but the '&' character is causing the following exception: "{"The remote server returned an error: (404) Not Found."}"

    Any clue how to workaround these constraints anyone?

    Monday, August 12, 2013 10:52 AM
  • User503812343 posted

    Yes you can pass multiple parameters to WCF RESTful services.  Make sure the UriTemplate of WebInvoke should be set properly

    [WebInvoke(Method = "POST", UriTemplate = "/Transaction/id/somevalue", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]

    if You have more than 4-5 values to post so you can use data contracts to get and post data to RESTful services.

    Click here to see how to use DataContract with RESTful services

    Monday, August 12, 2013 11:05 AM
  • User-1225287840 posted

    Try replacing '&' with &

    Monday, August 12, 2013 11:13 AM
  • User2043281626 posted

    Here is my Operation Contract for my RESTful service:

            [WebInvoke(Method = "GET",
                ResponseFormat = WebMessageFormat.Xml,
                BodyStyle = WebMessageBodyStyle.Wrapped,
                UriTemplate = "GetLookup{_Params}")]
            string GetLookup(string _Params);

    The web application calling the service prepares and makes the call as so:

    string sParam = "LookupID=" + 0001100011 + "&LookupTableName=" + Hello;
    oXml.Load(http://somewebservices.dev:1900/MyWS.svc/GetLookup + "?" + sParam);

    I get the following message:

    Endpoint not found.

    What am I missing here? Can this not be done with a "GET"? Please keep in mind, I can change very little in regards the web application calling the service. At most I can modify the URL being used, which I am doing to make it point at my service, beyond that I have very little control.

    Can I accomplish this with what I have just explained?

    Monday, August 12, 2013 11:22 AM