oclockvn
9/19/2015 - 10:20 AM

get-all.cs

public List<object> Get(string request, string token="")
{
    if (!string.IsNullOrEmpty(token))
    {
        _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
    }

    var resp = _client.GetAsync(request).Result;

    if (!resp.IsSuccessStatusCode)
    {
        return null;
    }

    try
    {
        return resp.Content.ReadAsAsync<List<object>>().Result;
    }
    catch (Exception ex)
    {
        throw ex;
    }
}