public async Task Notify(NotificationMessage message) { var serviceEndPoint = new Uri(GetOptions().Teams.WebhookUri); var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, serviceEndPoint) { Content = new StringContent( _messageBuilder.CreateMessage(message).ToString(), Encoding.UTF8, "application/json") }; try { var response = await client.SendAsync(request); GetLogger().LogTrace($"Message sent. {response.StatusCode} -> {response.Content}"); } catch (AggregateException e) { foreach (var exception in e.Flatten().InnerExceptions) { GetLogger().LogError(exception, $"Failed to send message. {exception.Message}"); } throw; } }
public async Task Notify(NotificationMessage message) { var serviceEndPoint = new Uri(GetOptions().Slack.WebhookUri); var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, serviceEndPoint) { Content = new StringContent( _messageBuilder.CreateMessage(message).ToString(), Encoding.UTF8, "application/json") }; var response = await client.SendAsync(request); GetLogger().LogTrace($"Message sent. {response.StatusCode} -> {response.Content}"); }