diff --git a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/PostEndpoint.cs b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/PostEndpoint.cs index 6f787ae4d..4081bc4dc 100644 --- a/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/PostEndpoint.cs +++ b/src/modules/Elsa.Workflows.Api/Endpoints/WorkflowDefinitions/Execute/PostEndpoint.cs @@ -30,19 +30,24 @@ internal class PostEndpoint( { PostRequest? request = null; - if (HttpContext.Request.ContentLength > 0 && (HttpContext.Request.ContentType?.Contains("application/json") ?? true)) + if (HttpContext.Request.ContentType?.Contains("application/json") ?? false) { - try + using var reader = new StreamReader(HttpContext.Request.Body); + var body = await reader.ReadToEndAsync(); + + if (!string.IsNullOrWhiteSpace(body)) { - request = await JsonSerializer.DeserializeAsync(HttpContext.Request.Body, - new JsonSerializerOptions + try { - PropertyNameCaseInsensitive = true - }, cancellationToken: cancellationToken); - } - catch - { - AddError("Invalid request body."); + request = JsonSerializer.Deserialize(body, new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }); + } + catch + { + AddError("Invalid request body."); + } } }