Skip to content

Commit

Permalink
Fix: #5533 - Enabled reading request body for HTTP POST requests. (#1…
Browse files Browse the repository at this point in the history
…3853)

Co-authored-by: emrah.tokalak <[email protected]>
Co-authored-by: Sébastien Ros <[email protected]>
  • Loading branch information
3 people authored Feb 2, 2024
1 parent 8c3a2fd commit 042caa6
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace OrchardCore.Queries.Controllers
Expand Down Expand Up @@ -43,7 +46,13 @@ public async Task<IActionResult> Query(
return NotFound();
}

var queryParameters = parameters != null ?
if (Request.Method == HttpMethods.Post && string.IsNullOrEmpty(parameters))
{
using var reader = new StreamReader(Request.Body, Encoding.UTF8);
parameters = await reader.ReadToEndAsync();
}

var queryParameters = !string.IsNullOrEmpty(parameters) ?
JConvert.DeserializeObject<Dictionary<string, object>>(parameters)
: [];

Expand Down

0 comments on commit 042caa6

Please sign in to comment.