4

I've created an OData endpoint (using entity framework, WCF data service)

and added a custom test WebGet test method like so:

    [WebGet(UriTemplate = "{text}")]
    public IQueryable<string> SplitString(string text)
    {
        if (text == null) throw new DataServiceException("text not specified");
        var result = (from s in text.Split('-') orderby s select s);
        return result.AsQueryable();
    }

and a config line:

    config.SetServiceOperationAccessRule("SplitString", ServiceOperationRights.All);

However, no matter how I specify the url, I can not get the text param to be filled out. (it is always null).

so:
http://localhost/myservice.svc/SplitString/testtext

does not work (It throws my Exception since the param is null). What is the correct url format (or UriTemplate) one should use to get the parameter to work?

The only examples I found of odata and WebGet only have an example method which doesn't have any parameters.

Toad
  • 15,593
  • 16
  • 82
  • 128

1 Answers1

7

The right way is: /myservice.svc/SplitString?testtext='mystringvalue'

See this page for more details: http://msdn.microsoft.com/en-us/library/cc668788.aspx

Vitek Karas MSFT
  • 13,130
  • 1
  • 34
  • 30
  • What do you mean by no way of making this work with DataService? Could you please describe you question in more detail (and preferably as a separate question)? – Vitek Karas MSFT Sep 08 '11 at 15:25