Skip to content

Commit

Permalink
Merge pull request #219 from bcgov/yj
Browse files Browse the repository at this point in the history
chore: fix duplicate header bug
  • Loading branch information
ychung-mot authored Apr 23, 2024
2 parents 0dfe686 + 69cd5a8 commit fc3f7d2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/StrDss.Service/EmailMessageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ public async Task<string> SendEmailAsync(EmailContent emailContent)
var token = await _chesTokenApi.GetTokenAsync();
var chesUrl = _config.GetValue<string>("CHES_URL") ?? "";

_httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token!.AccessToken}");
if (_httpClient.DefaultRequestHeaders.Contains("Authorization"))
{
_httpClient.DefaultRequestHeaders.Remove("Authorization");
_httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token!.AccessToken}");
}
else
{
_httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token!.AccessToken}");
}

var jsonContent = emailContent.ToString();
var httpContent = new StringContent(jsonContent, Encoding.UTF8, "application/json");
Expand Down

0 comments on commit fc3f7d2

Please sign in to comment.