I've used the hint in this thread and provided a default value, so that when a user doesnät specify the virutal sub-directory, I'm making the assumption that he meant all the stuff to be listed. It works.
[OperationContract]
[WebInvoke(UriTemplate = "GetStuff/{type=all}", ...]
IEnumerable<Stuff> GetStuff(String type);
However, it would be nicer to specify a default value, instead. However, default(String) is null and I'd like to sent in an actual value. Particularly, I've set my heart on String.Empty. However, I noticed that the following doesn't work. The condition on server side doesn't recognize the empty string (...where 'type' in (ColName, '', 'all')).
[OperationContract]
[WebInvoke(UriTemplate = "GetStuff/{type=String.Empty}", ...]
IEnumerable<Stuff> GetStuff(String type);
What to do?
It worked with "=null" for me. My contract looks like this:
You do have the ability to add an optional parameter to your URITemplate. However, it has to be the last parameter.
Optional UriTemplate parameter using WebGet
You can't really have an empty default value in an UriTemplate, but you can have something which will mean a default value, and at the operation you can replace that with the actual default value you want, as shown below.
when adding only '=' to get a default value which is empty for string variable it throws the message
instead assign a default value and check later in the code:
service id will be default value.