From 022e808b143d6c4b70e18970a4f9c2907b4071a9 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Tue, 2 Sep 2025 12:12:26 +0200 Subject: [PATCH] allow API post single value (with content-Type:application/json) --- src/web/WebAPIService.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index 89f23ad47..e17419825 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -38,12 +38,15 @@ void WebAPIService::webAPIService(AsyncWebServerRequest * request, JsonVariant j JsonDocument input_doc; // has no body JSON so create dummy as empty input object JsonObject input; // if no body then treat it as a secure GET - if ((request->method() == HTTP_GET) || (!json.is())) { + if (request->method() == HTTP_GET) { // HTTP GET input = input_doc.to(); - } else { + } else if (json.is()) { // HTTP_POST input = json.as(); // extract values from the json. these will be used as default values + } else { + input = input_doc.to(); + input["data"] = json.as(); } parse(request, input); }