I have following web api controller:
public class ProductController : ProductControllerBase
{
public async Task<string> Lookup(string id)
{
// do lookup
}
public async Task<string> Search(string keywords)
{
// do search
}
}
Sample requests to this api:
http://localhost/api/product/Lookup?provider=amazon&id=B07CSPSMQY
http://localhost/api/product/Lookup?provider=walmart&id=4132478AB
http://localhost/api/product/Lookup?provider=ebay&id=EWRHNFKASDN231
I am fetching provider in base class, because I use it for IoC purposes:
public ProductControllerBase()
{
string provider = HttpContext.Current.Request.QueryString["provider"];
// resolve search provider depending on parameter
SetController(provider);
}
In my WebApiConfig I have following setup:
config.Routes.MapHttpRoute(
"ProductControllerLookup",
"api/product/Lookup/{provider}/{id}",
new
{
}
);
but once I run URLs above, I keep getting following error:
{"Message":"The requested resource does not support http method 'GET'."}
What I want is to fetch parameters other than "provider", since I did not want to use it for all methods.
How can I configure this one?