Skip to content

Commit

Permalink
Fix Slack notification webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
arktronic committed Jul 3, 2023
1 parent 09305e8 commit 045c65e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion sama/Services/SlackNotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ protected virtual void SendNotification(string message)
using var httpHandler = _serviceProvider.GetRequiredService<HttpClientHandler>();
using var client = new HttpClient(httpHandler, false);
var data = JsonConvert.SerializeObject(new { text = message });
client.PostAsync(url, new StringContent(data)).Wait();
var content = new StringContent(data);
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
using var response = client.PostAsync(url, content).Result;
if (!response.IsSuccessStatusCode)
{
_logger.LogError(0, $"Unable to send Slack notification: HTTP {(int)response.StatusCode}", new Exception(response.Content.ReadAsStringAsync().Result));
}
}
catch (Exception ex)
{
Expand Down
4 changes: 2 additions & 2 deletions sama/sama.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<UserSecretsId>aspnet-WebApplication1-1C1369D5-B3C7-4414-ADD2-629BA88766C5</UserSecretsId>
<AssemblyVersion>1.2.2</AssemblyVersion>
<VersionPrefix>1.2.2</VersionPrefix>
<AssemblyVersion>1.2.3</AssemblyVersion>
<VersionPrefix>1.2.3</VersionPrefix>
<VersionSuffix>$([System.DateTime]::UtcNow.ToString(`yyyyMMdd-HHmm`))</VersionSuffix>
</PropertyGroup>

Expand Down

0 comments on commit 045c65e

Please sign in to comment.