# Error code on JSON API

**URL:** <https://forum.canton.network/t/error-code-on-json-api/4825>\
**Category:** App Development\
**Created:** [July 2, 2022, 11:37am UTC](https://forum.canton.network/t/error-code-on-json-api/4825 "2022-07-02T11:37:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frankie](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/frankie/32/646_2.png) [@Frankie](https://forum.canton.network/u/Frankie)\
**Post date:** [July 2, 2022, 11:37am UTC](https://forum.canton.network/t/error-code-on-json-api/4825/1 "2022-07-02T11:37:17Z")

</div>

Hi there,

With the new error code introduced since 1.18. Are they mapped to JSON API response as well? e.g. does the user get (DEADLINE\_EXCEEDED - REQUEST\_TIME\_OUT), ( ABORTED - RESOURCE\_EXHAUSTED) or ( UNAVAILABLE - INDEX\_DB\_SQL\_TRANSIENT\_ERROR) on JSON interface?

---

<div class="post-metadata">

**Author:** ![Raymond\_Roestenburg](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/raymond_roestenburg/32/3426_2.png) [@Raymond\_Roestenburg](https://forum.canton.network/u/Raymond_Roestenburg)\
**Post date:** [July 4, 2022, 9:57am UTC](https://forum.canton.network/t/error-code-on-json-api/4825/2 "2022-07-04T09:57:00Z")

</div>

Hi Frankie,

Yes, the com.google.rpc.Code error code is mapped to the JSON API response.

DEADLINE\_EXCEEDED maps to GATEWAY\_OUT (504).  
ABORTED maps to CONFLICT (409)  
UNAVAILABLE maps to SERVICE\_UNAVAILABLE (503)

See the complete mapping below, from G (gRPC) to A (HTTP):

```
  case G.OK => A.OK
  case G.INVALID_ARGUMENT | G.FAILED_PRECONDITION | G.OUT_OF_RANGE => A.BadRequest
  case G.UNAUTHENTICATED => A.Unauthorized
  case G.PERMISSION_DENIED => A.Forbidden
  case G.NOT_FOUND => A.NotFound
  case G.ABORTED | G.ALREADY_EXISTS => A.Conflict
  case G.RESOURCE_EXHAUSTED => A.TooManyRequests
  case G.CANCELLED => ClientClosedRequest
  case G.DATA_LOSS | G.UNKNOWN | G.UNRECOGNIZED | G.INTERNAL => A.InternalServerError
  case G.UNIMPLEMENTED => A.NotImplemented
  case G.UNAVAILABLE => A.ServiceUnavailable
  case G.DEADLINE_EXCEEDED => A.GatewayTimeout
  case G.UNAUTHENTICATED | G.CANCELLED => A.InternalServerError

```

Kind regards  
Ray

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephen/32/102_2.png) [@Stephen](https://forum.canton.network/u/Stephen)\
**Post date:** [July 5, 2022, 3:24pm UTC](https://forum.canton.network/t/error-code-on-json-api/4825/3 "2022-07-05T15:24:59Z")

</div>

Caveat to the above mapping, the last `case` overrides some of the prior cases. (`UNAUTHENTICATED` means there was a problem in `json-api`, since it checks for the presence of JWT itself. Likewise, json-api never cancels requests itself so such a grpc error means a problem within json-api.)
