title: Call get method in web api with multiple parameters from c#
body: <p>I am trying to invoke get method in web api which will take 2 parameters from client side. Here User will enter username &amp; password &amp; it will be sent to server for authentication.</p>
  
  <p>This is my controller Vendor (which I have created in mvc) &amp; its web api method</p>
  
  <pre><code>[Route("api/Vendor/{uname}/{pass}")]
      public int Get(string uname, string pass)
      {
          Boolean exists = false;
          int id = 0;
  
          SqlConnection con = new SqlConnection(" Data Source = DELL; Initial Catalog = EVENT; Integrated Security = True");
          con.Open();
          using (SqlCommand cmd = new SqlCommand("SELECT Count([UserName]) As Usercount FROM [dbo].[AllUser] WHERE [UserName] = '" + uname + "' AND [Password] = '" + pass + "' ", con))
          {
              exists = (int)cmd.ExecuteScalar() &gt; 0;
          }
  
          if (exists)
          {
              SqlCommand cmd = new SqlCommand("SELECT [Id] FROM [dbo].[AllUser] WHERE [UserName] = '" + uname + "' AND [Password] = '" + pass + "' ", con);
              SqlDataAdapter da = new SqlDataAdapter(cmd);
              DataSet ds = new DataSet();
              da.Fill(ds);
              id = Convert.ToInt16(ds.Tables[0].Rows[0][0]);
          }
          return id;
      }
  </code></pre>
  
  <p>Now I am stuck as how to send 2 parameters to this api. Do I have to convert them into JSON or can I simply send them directly. I don't know how to call this get mehod.<br>
  I am using c# and android at client side. Please, give me suggestions on how to invoke this method from both side.<br></p>
  
  <p>Thanks.</p>
  
  <p>Actually i updated my c# client side with the following code</p>
  
  <pre><code> static async Task&lt;int&gt; ValidateVendorAsync(string uname, string pass)
  {
      int id = 0;
      using (var client = new HttpClient())
      {
  
          client.BaseAddress = new Uri("http://localhost:56908/");
          client.DefaultRequestHeaders.Accept.Clear();
          client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
          client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
  
          HttpResponseMessage response = await client.GetAsync("api/Vendor/" + uname + "/" + pass);
          if (response.IsSuccessStatusCode)
          {
              System.Diagnostics.Debug.WriteLine("Con");
          }
          else
          {
              System.Diagnostics.Debug.WriteLine("Connection Error");
          }
  
  
          return id;
      }
  
  }
  </code></pre>
  
  <p>But the code doesn't work. The code after <strong>await client.GetAsync</strong> is not executing.
  How to solve this?</p>