Question

How to declare optional parameters in UriTemplate in WCF Web Api ? For example :

[WebGet(UriTemplate = "?culture={culture}")]
HttpResponseMessage<IEnumerable<Contact>> GetAll();

I need culture to be optional parameter. If culture is not passed I want to receive null for that param.

PS. I don't want to create solution with multiple GetAll methods with different UriTemplates...

Was it helpful?

Solution

With the following method declaration culture parameter will be null

[WebGet(UriTemplate = "?culture={culture}")]
HttpResponseMessage<IEnumerable<Contact>> GetAll(string culture);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top