From 0085f9862e75018b35f942945648b6c4be5f9526 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Fri, 17 Nov 2023 14:35:43 +0100 Subject: [PATCH] V13: Fix proper serialization of webhook object (#15248) * deserialize object again before firing * Dont serialize and already serialized object * Update to use constant instead of hard coded string --- .../BackgroundJobs/Jobs/WebhookFiring.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Infrastructure/BackgroundJobs/Jobs/WebhookFiring.cs b/src/Umbraco.Infrastructure/BackgroundJobs/Jobs/WebhookFiring.cs index fe8cf1e204..951c121982 100644 --- a/src/Umbraco.Infrastructure/BackgroundJobs/Jobs/WebhookFiring.cs +++ b/src/Umbraco.Infrastructure/BackgroundJobs/Jobs/WebhookFiring.cs @@ -1,4 +1,5 @@ -using System.Text; +using System.Net.Mime; +using System.Text; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Umbraco.Cms.Core; @@ -87,12 +88,11 @@ public class WebhookFiring : IRecurringBackgroundJob })); } - private async Task SendRequestAsync(Webhook webhook, string eventName, object? payload, int retryCount, CancellationToken cancellationToken) + private async Task SendRequestAsync(Webhook webhook, string eventName, string? serializedObject, int retryCount, CancellationToken cancellationToken) { using var httpClient = new HttpClient(); - var serializedObject = _jsonSerializer.Serialize(payload); - var stringContent = new StringContent(serializedObject, Encoding.UTF8, "application/json"); + var stringContent = new StringContent(serializedObject ?? string.Empty, Encoding.UTF8, MediaTypeNames.Application.Json); stringContent.Headers.TryAddWithoutValidation("Umb-Webhook-Event", eventName); foreach (KeyValuePair header in webhook.Headers)