I have a methoth in my web api like this:
public HttpResponseMessage Get(string path)
{
}
This is the corresponding URL:
http://server/web/api/controller?path='param'
But I want this query-string parameter optional.
I expect, if there is no query-string parameter, the string ‘path’ should be null.
But this is not working…
I have to create another method (otherwise the ‘method’ is not found)
public HttpResponseMessage Get()
Is there no other way?
Try providing a default value and explicitly stating it is from the Uri.