title: Unable to hit the created Post API in ASP.NET MVC
body: <p>I have an API which i am using to register a user.</p>
  
  <p>this is the code of Api.</p>
  
  <pre><code>public class AccountsController : ApiController
  {
      [HttpPost]
      [ActionName("Register")]
      public HttpResponseMessage Register(string SystemKey, string IPAddress, [FromUri]DomainModels.InstaUser.User user)
      {
          SessionUser _user = new SessionUser(user);
          if (!ValidateSystemKey(SystemKey))
          {
              return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Invalid Security Key");
          }
          else if (string.IsNullOrWhiteSpace(IPAddress))
          {
              return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "Invalid IP Address");
          }
          else if (Models.User.AlreadyExists(user.Username))
          {
              return Request.CreateErrorResponse(HttpStatusCode.Conflict, "Username already registered");
          }
          else if (Models.User.AlreadyExistsPhone(user.Phone))
          {
              return Request.CreateErrorResponse(HttpStatusCode.Conflict, "Phone Number already registered");
          }
          else if (DomainModels.InstaUser.User.Register(user, IPAddress))
          {
              CreateTokens(_user, IPAddress);
              return Request.CreateResponse(HttpStatusCode.OK, user);
          }
          else
          {
              return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to register user due to techincal issues");
          }
      }
  }
  </code></pre>
  
  <p>Here is the Route</p>
  
  <pre><code>///{SystemKey}/{IPAddress}/{Username}/{Password}/{Name}/{Email}/{Phone}/{Type}
          config.Routes.MapHttpRoute(
             name: "Register",
             routeTemplate: "api/Accounts/Register",
             defaults: new { controller = "Accounts", action = "Register", SystemKey = RouteParameter.Optional, IPAddress = RouteParameter.Optional, Username = RouteParameter.Optional, Password = RouteParameter.Optional, Name = RouteParameter.Optional,  Email = RouteParameter.Optional, Phone = RouteParameter.Optional, Type = RouteParameter.Optional }
             );
  </code></pre>
  
  <p>I have also tried adding and removing optional parameters.</p>
  
  <p>This is how i am trying to hit it.</p>
  
  <pre><code>        Dictionary&lt;string, string&gt; Params = new Dictionary&lt;string, string&gt;();
          Params.Add("SystemKey", ServerConfig.SystemKey);
          Params = Params.Union(Common.ConvertToDictionary(data)).ToDictionary(x=&gt;x.Key, x =&gt;x.Value); // data is a SessionUser object that i am taking input
          using (HttpClient client = new HttpClient())
          {
              var parameters = new FormUrlEncodedContent(nameValueCollection: Params);
              string Path = ServerConfig.server_path + "api/Accounts/Register";
              var response = client.PostAsJsonAsync(Path, parameters).Result;
              //var response = client.PostAsync(Path, parameters).Result; both give same response of 404
  
          }
  </code></pre>
  
  <p>API is not being hit and response contains 404 Not found.</p>
  
  <p>I am able to hit api using postman. but c# code isn't hitting the api.</p>