1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

api: allow failed actions to return a response

This commit is contained in:
Steffen Vogel 2017-08-10 13:31:34 +02:00
parent 62bc153270
commit 9d7d9badfc

View file

@ -64,7 +64,8 @@ int api_session_run_command(struct api_session *s, json_t *json_in, json_t **jso
char *id;
struct plugin *p;
json_t *json_args = NULL, *json_resp;
json_t *json_args = NULL;
json_t *json_resp = NULL;
ret = json_unpack(json_in, "{ s: s, s: s, s?: o }",
"action", &action,
@ -99,10 +100,12 @@ int api_session_run_command(struct api_session *s, json_t *json_in, json_t **jso
"code", ret,
"error", "command failed");
else
*json_out = json_pack("{ s: s, s: s, s: o }",
*json_out = json_pack("{ s: s, s: s }",
"action", action,
"id", id,
"response", json_resp);
"id", id);
if (json_resp)
json_object_set(*json_out, "response", json_resp);
out: debug(LOG_API, "API request completed with code: %d", ret);