I have a problem with IRestResponse in the below:
public async Task<CezanneToken> GetAccessToken()
{
var client = new RestClient(WebConfigurationManager.AppSettings["TokenUrl"]);
var request = new RestRequest();
request.Method = Method.Post;
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "grant_type=client_credentials&client_id=" + WebConfigurationManager.AppSettings["ClientId"] + "&client_secret=" + WebConfigurationManager.AppSettings["ClientSecret"] + "", ParameterType.RequestBody);
IRestResponse response = await client.ExecuteAsync(request);
string serStatus = ((RestResponseBase)response).Content;
CezanneToken details = JsonConvert.DeserializeObject<CezanneToken>(serStatus);
string Token = details.access_token;
return details;
}
IRestResponse throws the The type or namespace name "IRestResponse" could not be found (are you missing a using directive or an assembly reference?) error and I cannot make it work. IntelliSense suggest to go with RestResponse instead of IRestResponse.
But when I go with RestResponse I get Bad Request on the response.
The code sample above is "translated" from Visual Basic but it works just fine in VB. I don't know if the problem with the Bad Request comes from using RestResponse but I assume IRestResponse is needed just as in VB.
I've also seen people using IRestResponse but it just doesn't work for me. I have the using RestSharp; but do I need something else as well?