Added support for JSON content type in APIv1 and APIv2 calls

This commit is contained in:
Thulinma 2023-07-19 01:45:07 +02:00
parent b0d4422d27
commit f19899aed2

View file

@ -384,7 +384,13 @@ int Controller::handleAPIConnection(Socket::Connection &conn){
}
}
JSON::Value Response;
JSON::Value Request = JSON::fromString(H.GetVar("command"));
JSON::Value Request;
std::string reqContType = H.GetHeader("Content-Type");
if (reqContType == "application/json"){
Request = JSON::fromString(H.body);
}else{
Request = JSON::fromString(H.GetVar("command"));
}
// invalid request? send the web interface, unless requested as "/api"
if (!Request.isObject() && H.url != "/api" && H.url != "/api2"){
#include "server.html.h"