title: call web api by passing simple and complex parameter
body: <p>Getting an error message of no http resource or action found in controller. In a web api I have a from body and from uri parameter.            </p>
  
  <pre><code>[HttpPost]        
  public IHttpActionResult processfields(
      [FromUri]string field1,
      [FromUri]string field2, 
      [FromBody] string field3, 
      [FromUri]string field4
  ){...}
  </code></pre>
  
  <p>In the client I want to call the web api by doing--</p>
  
  <pre><code>using (var client = new HttpClient())
  {
      //set up client
      client.BaseAddress = new Uri(Baseurl);
      client.DefaultRequestHeaders.Clear();
      client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
  
       var values = new Dictionary&lt;string, string&gt;();
       values.Add("field1", field1);
       values.Add("field2", field2);
       values.Add("field3", field3);
       values.Add("field4", filed4);
  
  
       var jsonString = JsonConvert.SerializeObject(values);
       try
       {
  
           HttpResponseMessage Res = client.PostAsync("api/home/processfields", new StringContent(jsonString, Encoding.UTF8, "application/json")).Result;
           var result = Res.Content.ReadAsStringAsync();
       }
  }
  </code></pre>
  
  <p>While debugging, it executes the last line above but nothing happens and error message says--</p>
  
  <blockquote>
    <p>{"Message":"No HTTP resource was found that matches the request URI '<a href="http://xxx.xxx.xx.xx:1234/api/home/processfields" rel="nofollow noreferrer">http://xxx.xxx.xx.xx:1234/api/home/processfields</a>'.","MessageDetail":"No action was found on the controller 'home' that matches the request."}</p>
  </blockquote>
  
  <p>my webapi.config has</p>
  
  <pre><code>// Web API routes
  config.MapHttpAttributeRoutes();
  
  
  config.Routes.MapHttpRoute(
      name: "DefaultApi",
      routeTemplate: "api/{controller}/{action}/{id}",
      defaults: new { id = RouteParameter.Optional }
  );
  </code></pre>