From 5b62c82a49fe5e81d3543ce00d81304072b55c40 Mon Sep 17 00:00:00 2001 From: Henning Moe Date: Wed, 11 Oct 2023 12:35:36 +0200 Subject: [PATCH] Change Polymath to use JsonContent rather than StringContent. Resolves #331. --- src/VaultSharp/Core/Polymath.cs | 5 +++-- src/VaultSharp/VaultSharp.csproj | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/VaultSharp/Core/Polymath.cs b/src/VaultSharp/Core/Polymath.cs index bab2e03..84637c3 100644 --- a/src/VaultSharp/Core/Polymath.cs +++ b/src/VaultSharp/Core/Polymath.cs @@ -12,6 +12,7 @@ using VaultSharp.V1.Commons; using System.Text.Json.Nodes; using System.Text.Json; +using System.Net.Http.Json; namespace VaultSharp.Core { @@ -199,7 +200,7 @@ protected async Task MakeRequestAsync(string resourcePath, var requestUri = new Uri(_httpClient.BaseAddress, new Uri(resourcePath, UriKind.Relative)); var requestContent = requestData != null - ? new StringContent(JsonSerializer.Serialize(requestData), Encoding.UTF8) + ? JsonContent.Create(requestData) : null; HttpRequestMessage httpRequestMessage = null; @@ -233,7 +234,7 @@ protected async Task MakeRequestAsync(string resourcePath, httpRequestMessage = new HttpRequestMessage(httpMethod, requestUri) { Content = requestData != null - ? new StringContent(JsonSerializer.Serialize(requestData), Encoding.UTF8, "application/merge-patch+json") + ? JsonContent.Create(requestData, mediaType: new System.Net.Http.Headers.MediaTypeHeaderValue("application/merge-patch+json")) : null }; diff --git a/src/VaultSharp/VaultSharp.csproj b/src/VaultSharp/VaultSharp.csproj index 4accb0c..4778562 100644 --- a/src/VaultSharp/VaultSharp.csproj +++ b/src/VaultSharp/VaultSharp.csproj @@ -96,6 +96,9 @@ This library is built with .NET Standard 2.0, .NET Standard 2.1, 4.6.2, 4.7.2*, 7.0.2 + + 7.0.1 + @@ -105,6 +108,9 @@ This library is built with .NET Standard 2.0, .NET Standard 2.1, 4.6.2, 4.7.2*, 7.0.2 + + 7.0.1 + @@ -114,6 +120,9 @@ This library is built with .NET Standard 2.0, .NET Standard 2.1, 4.6.2, 4.7.2*, 7.0.2 + + 7.0.1 + @@ -123,6 +132,9 @@ This library is built with .NET Standard 2.0, .NET Standard 2.1, 4.6.2, 4.7.2*, 7.0.2 + + 7.0.1 + @@ -136,6 +148,9 @@ This library is built with .NET Standard 2.0, .NET Standard 2.1, 4.6.2, 4.7.2*, 7.0.2 + + 7.0.1 + @@ -149,6 +164,9 @@ This library is built with .NET Standard 2.0, .NET Standard 2.1, 4.6.2, 4.7.2*, 7.0.2 + + 7.0.1 + @@ -160,6 +178,9 @@ This library is built with .NET Standard 2.0, .NET Standard 2.1, 4.6.2, 4.7.2*, 7.0.2 + + 7.0.1 + @@ -170,6 +191,9 @@ This library is built with .NET Standard 2.0, .NET Standard 2.1, 4.6.2, 4.7.2*, 7.0.2 + + 7.0.1 +