I am creating web api as follows.
public class ProductsController : ApiController { //Get Products Prices
public string GetProductPrices(string ProductName)
{
//some method definition
} } I have defined webapiconfig as follows.
config.Routes.MapHttpRoute( name: "Default", routeTemplate: "api/{controller}/{action}/{ProductName}", defaults: new { controller = "Products", action = "GetProductPrices", ProductName= RouteParameter.Optional }); when i try calling web api from url,It gives me error 400.
I am calling the above method as follows.
1) http://site.com/api/Products/apple-ipod-touch/GetProductPrices 2) http://site.com/api/Products/GetProductPrices/apple-ipod-touch
Please correct my mistakes.