# Using confd\_seterr\_extended to give an error to REST client

**URL:** <https://dmap-community.ductus.global/t/using-confd-seterr-extended-to-give-an-error-to-rest-client/1572>\
**Category:** Other Northbound Interfaces\
**Created:** [October 4, 2017, 6:10pm UTC](https://dmap-community.ductus.global/t/using-confd-seterr-extended-to-give-an-error-to-rest-client/1572 "2017-10-04T18:10:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spothaka](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@spothaka](https://dmap-community.ductus.global/u/spothaka)\
**Post date:** [October 4, 2017, 6:10pm UTC](https://dmap-community.ductus.global/t/using-confd-seterr-extended-to-give-an-error-to-rest-client/1572/1 "2017-10-04T18:10:26Z")

</div>

I am trying to implement an external dataprovider from which I return CONFD\_ERR. I am trying to send set this error to a particular type of error code. I am setting this in get\_next\_object callback using the below lines of code. Is confd supposed to use this error code and return it to the REST client? I am not seeing any error returned to the end user. I also tried to set the same error in finish() callback but nothing is being shown to the REST Client. Anyone used this before?

# Code

```nohighlight
confd_trans_seterr_extended(tctx, CONFD_ERRCODE_ACCESS_DENIED, 0, 0, "");
return CONFD_ERR;

```

# dataprovider logs

```nohighlight
TRACE CALL data get_next_object(thandle=72, /urib/regular/vrf, -1)
--> CONFD_ERR
TRACE CALL trans finish(thandle=72) --> CONFD_ERR
TRACE Close user sess 100
--> CONFD_OK

```

# Developer logs

```nohighlight
<ERR> 4-Oct-2017::07:52:07.940 n9372-1 confd[25009]: devel-c get_next_object error {access_denied, ""} for callpoint 'routes-cp' path /ip-rib-ipv4-oper:urib/regular/vrf
<ERR> 4-Oct-2017::07:52:07.962 n9372-1 confd[25009]: devel-c close_trans error {access_denied, ""} daemon id: 1
<ERR> 4-Oct-2017::07:52:07.962 n9372-1 confd[25009]: devel-c close_trans/"urib_dp_daemon" error {access_denied, ""}

```

---

<div class="post-metadata">

**Author:** ![greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@greg](https://dmap-community.ductus.global/u/greg)\
**Post date:** [October 4, 2017, 6:38pm UTC](https://dmap-community.ductus.global/t/using-confd-seterr-extended-to-give-an-error-to-rest-client/1572/2 "2017-10-04T18:38:32Z")

</div>

In this case, what is the REST response that you are seeing?

---

<div class="post-metadata">

**Author:** ![spothaka](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@spothaka](https://dmap-community.ductus.global/u/spothaka)\
**Post date:** [October 4, 2017, 6:41pm UTC](https://dmap-community.ductus.global/t/using-confd-seterr-extended-to-give-an-error-to-rest-client/1572/3 "2017-10-04T18:41:46Z")

</div>

blank. I get code 200 OK but no response body.

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [October 6, 2017, 6:14pm UTC](https://dmap-community.ductus.global/t/using-confd-seterr-extended-to-give-an-error-to-rest-client/1572/4 "2017-10-06T18:14:36Z")

</div>

This seems like a bug in the legacy Tailf-f REST interface,  
The bug should be reported, but may I suggest that you, if possible, use the [IETF RFC8040 based RESTCONF protocol](https://tools.ietf.org/html/rfc8040) interface instead? No new project should use the legacy Tail-f REST interface, and RESTCONF works as expected here:

Inserted this into the examples.confd/intro/5-c\_stats/arpstat.c example:

```auto
static int get_next_object(struct confd_trans_ctx *tctx,
                             confd_hkeypath_t *keypath, long next)
{
    confd_trans_seterr_extended(tctx, CONFD_ERRCODE_ACCESS_DENIED, 0, 0, "get_next_object: CONFD_ERRCODE_ACCESS_DENIED");
    return CONFD_ERR;
}

```

RESTCONF (OK):

```nohighlight
$ curl -v -s -u admin:admin http://localhost:8008/restconf/data/arpentries
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8008 failed: Connection refused
* Trying fe80::1...
* TCP_NODELAY set
* Connection failed
* connect to fe80::1 port 8008 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8008 (#0)
* Server auth using Basic with user 'admin'
> GET /restconf/data/arpentries HTTP/1.1
> Host: localhost:8008
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.54.0
> Accept: */*
> 
< HTTP/1.1 403 Forbidden
< Server: 
< Date: Fri, 06 Oct 2017 08:18:05 GMT
< Content-Length: 303
< Content-Type: application/yang-data+xml
< Vary: Accept-Encoding
< 
<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
  <error>
    <error-message>get_next_object: CONFD_ERRCODE_ACCESS_DENIED</error-message>
    <error-path>/arpe:arpentries/arpe</error-path>
    <error-tag>access-denied</error-tag>
    <error-type>application</error-type>
  </error>
</errors>
* Connection #0 to host localhost left intact

```

REST (bug):

```nohighlight
$ curl -v -s -u admin:admin http://localhost:8008/api/operational/arpentries
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8008 failed: Connection refused
* Trying fe80::1...
* TCP_NODELAY set
* Connection failed
* connect to fe80::1 port 8008 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8008 (#0)
* Server auth using Basic with user 'admin'
> GET /api/operational/arpentries HTTP/1.1
> Host: localhost:8008
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.54.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: 
< Date: Fri, 06 Oct 2017 08:20:04 GMT
< Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
< Content-Length: 0
< Content-Type: text/html
< Pragma: no-cache
< 
* Connection #0 to host localhost left intact

```
