Aniket Narvankar

Aniket Narvankar

  • 536
  • 2.1k
  • 579.6k

Asp.Net WebAPI Question

Jul 3 2016 8:27 AM
I am new to webApi,I have cratead a api method
 
[HttpPost]
public string Test(string Name,string LastName)
{
    Register obj = new Register();
    string Message = obj.Insert(Name,LastName);
   return Message; 
 
Register is the Model in that have following
 
public string Name
{
get;
set; 
 
public string LastName
{
get;
set;
}
 
public string Insert(string Name,string Lastname)
{
     string message; 
    //Database logic 
     return message;
//message is success if insertion successful otherwise fail
 
I am trying to Call the web api through Rest Client as  follows
 
http://localhost:56611/api/Default1/Test
 
Default1 is controller name and Test is my method name. 
 
Name: Abc
LastName: Xyz
Content-Type: application/json
 
But it is not working gives 404 bad request error this is the message
No action was found on the controller 'Default1' that matches the request. 
 
Please do let me know about the solution how should i pass the parameters to web api from advanced rest client,i am new to this

Answers (3)