asp.net web api returns error 400

Posted by Arjunanss under ASP.NET on 10/17/2013 | Points: 10 | Views : 1105 | Status : [Member] | Replies : 0
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.




Responses

(No response found.)

Login to post response