From 166c212dec3d8684dc06957109362b2a3d2f52ee Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Wed, 15 Jun 2022 16:15:16 +0100 Subject: [PATCH] Adding in a hack to fix an issue whereby Dahomey.Json was throwing an InvalidOperationException: "Cannot skip tokens on partial JSON" exception when trying to use JsonSerializer.DeserializeAsync(stream). Links: https://github.com/dahomey-technologies/Dahomey.Json/issues/110 --- .../CaseManagementApiClient.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Exizent.CaseManagement.Client/CaseManagementApiClient.cs b/src/Exizent.CaseManagement.Client/CaseManagementApiClient.cs index 4153cd2..35fc2f0 100644 --- a/src/Exizent.CaseManagement.Client/CaseManagementApiClient.cs +++ b/src/Exizent.CaseManagement.Client/CaseManagementApiClient.cs @@ -1,6 +1,7 @@ using System.Globalization; using System.Net; using System.Net.Http.Json; +using System.Text.Json; using Exizent.CaseManagement.Client.Models; namespace Exizent.CaseManagement.Client; @@ -31,7 +32,8 @@ public CaseManagementApiClient(HttpClient httpClient) response.EnsureSuccessStatusCode(); - return await response.Content.ReadFromJsonAsync(DefaultJsonSerializerOptions - .Instance); + var body = await response.Content.ReadAsStringAsync(); + + return JsonSerializer.Deserialize(body, DefaultJsonSerializerOptions.Instance); } } \ No newline at end of file