我正在尝试从API获取身份验证令牌,但authResponse始终为NULL。
下面是我正在使用的代码以及我期望的实际JSON响应。知道它为什么总是NULL吗?
public static string GetAccessToken(string username, string password)
{
var authClient = new RestClient(authBaseURL);
var authRequest = new RestRequest();
var authenticationModel = "{ Email : " + username + ", Password : " + password + "}";
authRequest.AddParameter("application/json", authenticationModel, ParameterType.RequestBody);
var authResponse = authClient.Execute<Auth>(authRequest);
var accessToken = authResponse.Data.AccessToken;
return accessToken.Trim('"');
}
//JSON response
{
"AccessToken": "xxxxx"
}