async Task <string> GetPage(IApiRequest request, int page) { request.SetParameter("page", (page + 1).ToString()); var httpResponse = await GetHttpRequest(request); await CheckRateLimit(httpResponse); // Throw an exception if server errors in the middle of fetching pages if (!httpResponse.IsSuccessStatusCode) { throw new Exception($"Error fetching pages for '{request.RequestUri.AbsolutePath}' CODE {httpResponse.StatusCode}: {await httpResponse.Content.ReadAsStringAsync()}"); } return(await httpResponse.Content.ReadAsStringAsync()); }
/// <summary> /// Add auth token to the correct location accoridng to the login config /// </summary> /// <param name="request"></param> /// <param name="token"></param> void AddTokenLocation(IApiRequest request, string token) { switch (Config.TokenLocation) { case "header": request.SetHeader(Config.TokenName, token); break; case "query": request.SetParameter(Config.TokenName, token); break; default: throw new Exception("Invalid token location"); } }