12345678910111213141516171819202122232425262728293031 |
- using System;
- using System.Net.Http;
- using System.Text.Json;
- using System.Threading.Tasks;
- namespace sera_slackbot.Library
- {
- public class RestApiRequester
- {
- public async Task<dynamic> GetJson(string url)
- {
- var contentString = string.Empty;
- var client = new HttpClient();
- try
- {
- var response = await client.GetAsync(url);
- contentString = await response.Content.ReadAsStringAsync();
- return JsonSerializer.Deserialize<dynamic>(contentString);
- }
- catch (Exception e)
- {
- Console.WriteLine("Issue with making the curl; I tried " + url);
- Console.WriteLine(e.Message);
- }
- return contentString;
- }
- }
- }
|