title: How to call PUT method from Web Api using HttpClient?
body: <p>I want to call Api function (1st) . from 2nd Api function using <strong>HttpClient</strong>. But I always get <strong>404</strong> Error. </p>
  
  <p><strong>1st Api Function</strong> (<strong>EndPoint :</strong> http : // localhost : xxxxx /api/Test/)</p>
  
  <pre><code>public HttpResponseMessage Put(int id, int accountId, byte[] content)
  [...]
  </code></pre>
  
  <p><strong>2nd Api function</strong></p>
  
  <pre><code>public HttpResponseMessage Put(int id, int aid, byte[] filecontent)
  {
      WebRequestHandler handler = new WebRequestHandler()
      {
          AllowAutoRedirect = false,
          UseProxy = false
      };
  
      using (HttpClient client = new HttpClient(handler))
      {
          client.BaseAddress = new Uri("http://localhost:xxxxx/");
  
          // Add an Accept header for JSON format.
          client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
          var param = new object[6];
          param[0] = id;
          param[1] = "/";
          param[2] = "?aid="; 
          param[3] = aid;                           
          param[4] = "&amp;content=";
          param[5] = filecontent;
  
          using (HttpResponseMessage response = client.PutAsJsonAsync("api/Test/", param).Result)
          {
              return response.EnsureSuccessStatusCode();
          }
      }
  }
  </code></pre>
  
  <p>So My question is that. <strong>Can I post Method Parameter as an object array from HttpClient as I did ?</strong> I don't want to <strong>Pass model</strong> as method parameter.</p>
  
  <p>What is the wrong in my code ?</p>
  
  <p><strong>Unable to get any response , after change code to</strong> </p>
  
  <pre><code>return client.PutAsJsonAsync(uri, filecontent)
             .ContinueWith&lt;HttpResponseMessage&gt;
              (
                 task =&gt; task.Result.EnsureSuccessStatusCode()
              );
  </code></pre>
  
  <p>OR </p>
  
  <pre><code>return client.PutAsJsonAsync(uri, filecontent)
             .ContinueWith
              (
                 task =&gt; task.Result.EnsureSuccessStatusCode()
              );
  </code></pre>