RestSharp响应始终为NULL

时间:2017-06-21 15:21:18

标签: json restsharp

我正在尝试从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"
    }

0 个答案:

没有答案
相关问题