Sivakumar

Sivakumar

  • NA
  • 551
  • 211.4k

How to return a token value an windows form application

Sep 9 2015 2:56 AM
Hi,
 
I am Implemented windows form application for consuming web api and return values in windows form grid view.
 
like this :
 
 
 
When i click submit button it return a values like this :
 
 
 at the same how to implement login api using [Post] method and return  a token value  in a grid view.
 
this is my code for getting employee values :
 
private void button1_Click(object sender, EventArgs e)
{
URI = textBox2.Text + textBox1.Text;

GetAllEmployees();
}
#region Methods

private async void GetAllEmployees()
{
using (var client = new HttpClient())
{
using (var response = await client.GetAsync(URI))
{
if (response.IsSuccessStatusCode)
{
var productJsonString = await response.Content.ReadAsStringAsync();
dataGridView1.DataSource = JsonConvert.DeserializeObject<Employee[]>(productJsonString).ToList();
}
}
}
}

#endregion

public class Employee
{
public int Id { get; set; }

public string Name { get; set; }

public string desig { get; set; }

public decimal salary { get; set; }
}

}



 
I am using a rest tool and login successful and get a access token. but i want to get access token in windows form.
 
Please give me code for login api and get a token in gridview.