diff --git a/apps/restconf/restconf_methods.c b/apps/restconf/restconf_methods.c index c5032c8b..8cadab90 100644 --- a/apps/restconf/restconf_methods.c +++ b/apps/restconf/restconf_methods.c @@ -188,11 +188,18 @@ api_return_err(clicon_handle h, FCGX_FPrintF(r->out, " \r\n"); } else{ - FCGX_FPrintF(r->out, "{%s", pretty?"\r\n":""); - FCGX_FPrintF(r->out, " \"ietf-restconf:errors\" : {%s", pretty?"\r\n":""); - FCGX_FPrintF(r->out, " %s", cbuf_get(cb)); - FCGX_FPrintF(r->out, " }%s", pretty?"\r\n":""); - FCGX_FPrintF(r->out, "}\r\n"); + if (pretty){ + FCGX_FPrintF(r->out, "{\r\n"); + FCGX_FPrintF(r->out, " \"ietf-restconf:errors\" : %s\r\n", + cbuf_get(cb)); + 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: retval = 0; diff --git a/test/test_restconf.sh b/test/test_restconf.sh index d0515410..99920060 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -172,7 +172,7 @@ if [ -z "$match" ]; then fi 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" 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}\]}}