restconf json err return: too many {}

This commit is contained in:
Olof hagsand 2018-03-13 23:17:36 +00:00
parent 03be9c0567
commit 9b951b5ce6
2 changed files with 13 additions and 6 deletions

View file

@ -188,11 +188,18 @@ api_return_err(clicon_handle h,
FCGX_FPrintF(r->out, " </errors>\r\n"); FCGX_FPrintF(r->out, " </errors>\r\n");
} }
else{ else{
FCGX_FPrintF(r->out, "{%s", pretty?"\r\n":""); if (pretty){
FCGX_FPrintF(r->out, " \"ietf-restconf:errors\" : {%s", pretty?"\r\n":""); FCGX_FPrintF(r->out, "{\r\n");
FCGX_FPrintF(r->out, " %s", cbuf_get(cb)); FCGX_FPrintF(r->out, " \"ietf-restconf:errors\" : %s\r\n",
FCGX_FPrintF(r->out, " }%s", pretty?"\r\n":""); cbuf_get(cb));
FCGX_FPrintF(r->out, "}\r\n"); FCGX_FPrintF(r->out, "}\r\n");
}
else{
FCGX_FPrintF(r->out, "{");
FCGX_FPrintF(r->out, "\"ietf-restconf:errors\" : ");
FCGX_FPrintF(r->out, "%s", cbuf_get(cb));
FCGX_FPrintF(r->out, "}\r\n");
}
} }
ok: ok:
retval = 0; retval = 0;

View file

@ -172,7 +172,7 @@ if [ -z "$match" ]; then
fi fi
new "restconf Re-add subtree which should give error" new "restconf Re-add subtree which should give error"
expectfn 'curl -s -i -X POST -d {"interfaces":{"interface":{"name":"eth/0/0","type":"eth","enabled":true}}} http://localhost/restconf/data' '{"error-tag": "operation-failed"' expectfn 'curl -s -X POST -d {"interfaces":{"interface":{"name":"eth/0/0","type":"eth","enabled":true}}} http://localhost/restconf/data' '{"ietf-restconf:errors" : {"error": {"error-tag": "operation-failed","error-type": "protocol","error-severity": "error","error-message": "Object to create already exists"}}}'
new "restconf Check interfaces eth/0/0 added" new "restconf Check interfaces eth/0/0 added"
expectfn "curl -s -G http://localhost/restconf/data" '{"interfaces": {"interface": \[{"name": "eth/0/0","type": "eth","enabled": true}\]},"interfaces-state": {"interface": \[{"name": "eth0","type": "eth","if-index": 42}\]}} expectfn "curl -s -G http://localhost/restconf/data" '{"interfaces": {"interface": \[{"name": "eth/0/0","type": "eth","enabled": true}\]},"interfaces-state": {"interface": \[{"name": "eth0","type": "eth","if-index": 42}\]}}