I am trying to call custom name method name in webapi class. I am using Postman and able call Get
method but not CusActivity
method. Postman is not throwing any error either.
What is wrong here?
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "ApiWithAction",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
public class CusActivityController : ApiController
{
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
[HttpPost]
public string CusActivityInsert(string userToken, string masterCustomerId, string activityText)
{
}
}
In POSTMAN
{
"userToken": "userToken1",
"masterCustomerId": "3440214",
"activityText": "ID01-Membership."
}
Your API only has one parameter in config.
You need change parameter
of your action API to
public string CusActivityInsert(UserToken item)
{
}
with class
public class UserToken
{
public string userToken { get; set; }
public string masterCustomerId { get; set; }
public string activityText { get; set; }
}
If you want to keep current parameter, change PostMan API URL to
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.