I have been working on getting an api authentication to work and I am currently stuck on getting the response to execute to show up in a text box.
{
private void button1_Click(object sender, EventArgs e)
{
string user = textBoxUsername.Text;
string password = textBoxPassword.Text;
string tenant = comboBoxCompany.Text;
var client = new RestClient("https://server_name/v2/security/authenticate");
var request = new RestRequest();
request.Method = Method.Post;
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddHeader("accept", "application/json");
request.AddParameter("application/x-www-form-urlencoded",
"grantType=password&userName={{username}}&password={{password}}&tenant={{company_name}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request); <= //error here // red line is under the 'Execute'
textBoxJson.Text = response.ToString();
}
}
public class IRestResponse
{
public bool success { get; set; }
public List<AuthenticationResponseData> result { get; set; }
}
public class AuthenticationResponseData
{
public string accesstoken { get; set; }
public string refreshtoken { get; set; }
public string accessTokenExpiresOn { get; set; }
public string refreshTokenExpiresOn { get; set; }
}
This is within a form page.