From d3631a1d2552fd13762d73848ff35646aa6f198c Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos <1697880+AngelFQC@users.noreply.github.com> Date: Wed, 25 Jun 2025 11:47:35 -0500 Subject: [PATCH] Webservice: Allow receiving body content in JSON format - BT#22611 --- main/webservices/api/v2.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main/webservices/api/v2.php b/main/webservices/api/v2.php index bca1d19a2f6..1a1430fe642 100644 --- a/main/webservices/api/v2.php +++ b/main/webservices/api/v2.php @@ -23,6 +23,20 @@ $httpRequest = HttpRequest::createFromGlobals(); +$jsonContent = 'application/json' === $httpRequest->headers->get('Content-Type') + ? json_decode($httpRequest->getContent(), true) + : null; + +if ($jsonContent) { + foreach ($jsonContent as $key => $value) { + $value = Security::remove_XSS($value); + + $httpRequest->query->set($key, $value); + $httpRequest->request->set($key, $value); + $httpRequest->overrideGlobals(); + } +} + $hash = $httpRequest->query->get('hash'); if ($hash) {