diff --git a/Postgrest/Helpers.cs b/Postgrest/Helpers.cs index b9d17fa..8cb3db2 100644 --- a/Postgrest/Helpers.cs +++ b/Postgrest/Helpers.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json; using Postgrest.Responses; using System.Runtime.CompilerServices; +using Newtonsoft.Json.Linq; using Postgrest.Extensions; [assembly: InternalsVisibleTo("PostgrestTests")] @@ -82,8 +83,13 @@ public static async Task MakeRequest( if (data != null && method != HttpMethod.Get) { - requestMessage.Content = new StringContent(JsonConvert.SerializeObject(data, serializerSettings), - Encoding.UTF8, "application/json"); + var stringContent = JsonConvert.SerializeObject(data, serializerSettings); + + if (!string.IsNullOrWhiteSpace(stringContent) && JToken.Parse(stringContent).HasValues) + { + requestMessage.Content = new StringContent(stringContent, + Encoding.UTF8, "application/json"); + } } if (headers != null)