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