I want to make a web api that is passed 4 parameters.
Here is my route:
config.Routes.MapHttpRoute(
name: \"DefaultApi\",
Ensure you have default api route setting in WebApiConfig.cs file.
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "ContactApi",
routeTemplate: "api/{controller}/{email}/{firstname}/{lastname}/{source}"
);
}
}
http://fakedomain.com/api/Contacts/GetId?email=user@domain.com&firstname=joe&lastname=shmoe&source=123
Note : I replaced fakedomain with localhost and it works... (localhost/api/Contacts/GetId?email=user@domain.com&firstname=joe&lastname=shmoe&source=123)