private static async Task _populateBasicRedditInfo() { string?offset = null; var maxResults = 10000; var pageSize = 100; var totalResults = 0; var prevResults = 1; while (totalResults < maxResults && prevResults > 0) { await Task.Yield(); prevResults = 0; var url = "https://api.pushshift.io/reddit/search/submission/" + "?subreddit=dankditties&sort=desc&sort_type=created_utc" + "&size=" + pageSize; if (offset != null) { url += "&before=" + offset; } Console.WriteLine(url); var response = await _client.GetAsync(url); if (!response.IsSuccessStatusCode) { Console.WriteLine(await response.Content.ReadAsStringAsync()); return; } var responseText = await response.Content.ReadAsStringAsync(); var responseData = JsonConvert.DeserializeObject <dynamic>(responseText)?.data; if (responseData == null) { throw new Exception("reddit response data was null"); } foreach (var d in responseData) { var id = d?.id.ToString(); await _metadataManager?.AddRedditPostAsync(id, d?.url.ToString()); offset = d?.created_utc.ToString(); prevResults++; totalResults++; } } }