From cd0d19543ad4c12990d62a76bc43cd4d0d1dfae3 Mon Sep 17 00:00:00 2001 From: Macgyver Hoferkamp Date: Mon, 23 Feb 2026 09:26:24 -0600 Subject: [PATCH] Update the ContentSerializer Settings to allow data to POST back to AutoTask API. --- AutoTask.Psa.Api/AutoTask.Psa.Api.csproj | 2 +- AutoTask.Psa.Api/AutoTaskClient.cs | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/AutoTask.Psa.Api/AutoTask.Psa.Api.csproj b/AutoTask.Psa.Api/AutoTask.Psa.Api.csproj index c68ffd9..cd2cc86 100644 --- a/AutoTask.Psa.Api/AutoTask.Psa.Api.csproj +++ b/AutoTask.Psa.Api/AutoTask.Psa.Api.csproj @@ -41,7 +41,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/AutoTask.Psa.Api/AutoTaskClient.cs b/AutoTask.Psa.Api/AutoTaskClient.cs index 0609062..bb31221 100644 --- a/AutoTask.Psa.Api/AutoTaskClient.cs +++ b/AutoTask.Psa.Api/AutoTaskClient.cs @@ -1,5 +1,7 @@ using Newtonsoft.Json.Linq; using System.Text; +using System.Text.Json; +using System.Text.Json.Serialization; namespace AutoTask.Psa.Api; @@ -27,18 +29,13 @@ public AutoTaskClient(HttpClient client) _httpClient = client; _refitSettings = new RefitSettings { - //ContentSerializer = new NewtonsoftJsonContentSerializer( - // new JsonSerializerSettings - // { - // // By default nulls should not be rendered out, this will allow the receiving API to apply any defaults. - // // Use [JsonProperty(NullValueHandling = NullValueHandling.Include)] to send - // // nulls for specific properties, e.g. disassociating port schedule ids from a port - // NullValueHandling = NullValueHandling.Ignore, - // #if DEBUG - // MissingMemberHandling = MissingMemberHandling.Error, - // #endif - // Converters = new List { new StringEnumConverter() } - // }) + ContentSerializer = new SystemTextJsonContentSerializer( + new JsonSerializerOptions + { + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + WriteIndented = true, + }) }; ActionTypes = RefitFor(ActionTypes!); AdditionalInvoiceFieldValues = RefitFor(AdditionalInvoiceFieldValues!);