i tray to add new method in my rest web service but when i test it it give me error
it doesn't work when i add parameter but when i don't add parameter it work !
this is my code
[HttpGet]
[ActionName("rrrr")]
public String GetCDEF()
{
return "ddddddd";
}
[HttpGet]
[ActionName("rrrr")]
public string GetRetriveData(int s)
{
s = s * 3;
return s.ToString();
}
and the apiconfig
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Configure Web API to use only bearer token authentication.
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "ActionApi",
routeTemplate: "api/{controller}/{Action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
Member
1 Points
48 Posts
how to open method in rest web servics
Nov 21, 2016 09:26 AM|ohoud|LINK
hi
i tray to add new method in my rest web service but when i test it it give me error
it doesn't work when i add parameter but when i don't add parameter it work !
this is my code
and the apiconfig
Contributor
4790 Points
1211 Posts
Re: how to open method in rest web servics
Nov 25, 2016 04:12 PM|ketan_al|LINK
Hi,
Please change variable from "s" to "id" in GetRetriveData as follows
This is required because in route configuration "id" parameter specified as follows
http://www.ketscode.com
MCP, MCTS,MCPD (Microsoft Azure Developer)
Please mark as answer if it helps