Skip to content

Commit

Permalink
Don't use default serializer for eid logger post
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkoSekulic committed Oct 8, 2024
1 parent 8f7afb9 commit fd863a6
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
using System.Net.Http;
using System.Net.Mime;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace Altinn.Studio.Designer.TypedHttpClients.EidLogger;

public class EidLoggerClient : IEidLoggerClient
{
private readonly HttpClient _httpClient;
private readonly JsonSerializerOptions _jsonSerializerOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};

public EidLoggerClient(HttpClient httpClient)
{
Expand All @@ -14,7 +21,11 @@ public EidLoggerClient(HttpClient httpClient)

public async Task Log(EidLogRequest request)
{
var response = await _httpClient.PostAsJsonAsync("eid-event-log", request);
using var payloadContent = new StringContent(JsonSerializer.Serialize(request, _jsonSerializerOptions),
Encoding.UTF8,
MediaTypeNames.Application.Json);

using var response = await _httpClient.PostAsync("eid-event-log", payloadContent);
response.EnsureSuccessStatusCode();
}
}

0 comments on commit fd863a6

Please sign in to comment.