mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 22:24:44 +02:00
Merge pull request #6199 from Icinga/fix/action-http-code
Return 500 when no api action is successful
This commit is contained in:
commit
6d81c5c34f
@ -91,11 +91,23 @@ bool ActionsHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& reques
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int statusCode = 500;
|
||||||
|
String statusMessage = "No action executed successfully";
|
||||||
|
|
||||||
|
for (const Dictionary::Ptr& res : results) {
|
||||||
|
if (res->Contains("code") && res->Get("code") == 200) {
|
||||||
|
statusCode = 200;
|
||||||
|
statusMessage = "OK";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response.SetStatus(statusCode, statusMessage);
|
||||||
|
|
||||||
Dictionary::Ptr result = new Dictionary({
|
Dictionary::Ptr result = new Dictionary({
|
||||||
{ "results", new Array(std::move(results)) }
|
{ "results", new Array(std::move(results)) }
|
||||||
});
|
});
|
||||||
|
|
||||||
response.SetStatus(200, "OK");
|
|
||||||
HttpUtility::SendJsonBody(response, params, result);
|
HttpUtility::SendJsonBody(response, params, result);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user