ConfD User Community

Issue with action_seterr_extended

I used dp.action_seterr_extended(uninfo=self.uinfo,code=CONFD_ERRCODE_ACCESS_DENIED,apptag_ns=0,apptag_tag=0,errstr=err) instead of dp.action_seterr(self.uinfo, err). Internally action_seterr calls action_seterr_extended method but trying to change the status code.

Need 403 rest API error instead of 400 error

Try something like:

    def cb_action(self, uinfo, name, keypath, params):
        dp.action_seterr_extended(uinfo, _confd.ERRCODE_ACCESS_DENIED, 0, 0, "")
        return _confd.CONFD_ERR

Example:

POST http://localhost:8008/restconf/operations/config:config/system/reboot
status code: 403
{
  "ietf-restconf:errors": {
    "error": [
      {
        "error-type": "application",
        "error-tag": "access-denied",
        "error-path": "/config:config/system/reboot",
        "error-message": "access denied"
      }
    ]
  }
}