mirror of https://github.com/Icinga/icinga2.git
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({
|
||||
{ "results", new Array(std::move(results)) }
|
||||
});
|
||||
|
||||
response.SetStatus(200, "OK");
|
||||
HttpUtility::SendJsonBody(response, params, result);
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue