WCF Web Api optional parameters in UriTemplate

1.3k views Asked by At

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...

1

There are 1 answers

0
hskan On BEST ANSWER

With the following method declaration culture parameter will be null

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