public static async Task<string> GetByLastDate(string specificUrl, string token, DateTime date) // specificUrl like "user/" at the end "/" { var policy = Policy .Handle<Exception>() .OrResult<HttpResponseMessage>(r => !r.IsSuccessStatusCode) .RetryAsync(2); return await policy.ExecuteAsync(async() => { string fullUrl = baseUrl + specificUrl + date; using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, fullUrl)) { requestMessage.Headers.Add("access_token", token); using (HttpResponseMessage res = await client.SendAsync(requestMessage)) { string data = await res.Content.ReadAsStringAsync(); if (string.IsNullOrEmpty(data)) { return string.Empty; } return data; } } }).ConfigureAwait(false);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)