# Improve (add) friendly JSON API error messages (at least generic ones)

**URL:** https://meta.discourse.org/t/improve-add-friendly-json-api-error-messages-at-least-generic-ones/70272
**Category:** Feature
**Created:** [18 Settembre 2017, 12:44pm UTC](https://meta.discourse.org/t/improve-add-friendly-json-api-error-messages-at-least-generic-ones/70272 "2017-09-18T12:44:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dylanh724](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanh724/32/119642_2.png) [@dylanh724](https://meta.discourse.org/u/dylanh724)
#### Post date: [18 Settembre 2017, 12:44pm UTC](https://meta.discourse.org/t/improve-add-friendly-json-api-error-messages-at-least-generic-ones/70272/1 "2017-09-18T12:44:33Z")

</div>

If I POST to /posts and something is wrong, here is what’s returned as an error:

 ![image](https://global.discourse-cdn.com/meta/original/3X/a/1/a1dedcbd870b70a8174bb1c10e7c3d4a74081bcf.png)

![image](https://global.discourse-cdn.com/meta/original/3X/5/4/54a9586bcbc47852ad7e1bf18faa2feebe2aab30.png)

_only_ the code shows - no message (not friendly). This is the error when I typo the secret.

Here’s another form of error, leaving out a field:

![image](https://global.discourse-cdn.com/meta/original/3X/9/7/976b500e6799d1484a01244771f04f9b266729c4.png)

bad “CSRF” – No one knows what the heck does that means. You can see 403 forbidden and get the hint for the code, but let’s say it wasn’t a forbidden one: It goes back to the 500 error.

These errors… really suck haha. Suggestions:

**Invalid Parameters: Missing xx field(s)**

**Forbidden: Invalid secret/key combo**

_Something_ like these. Since error messages are so common, I actually thought I was glitched out since I only had a code returned, so even something generic would be better than nothing.

It would also be more intuitive if the errors were in json for consideration of future additions, and to be more intuitive to handling error standards of most other API’s.

```
{
  "error": {
    "msg": "Invalid API/Secret Combination: Extra info here",
    "code": "ACCESS_DENIED"
  {
}

```

Thoughts?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [18 Settembre 2017, 4:25pm UTC](https://meta.discourse.org/t/improve-add-friendly-json-api-error-messages-at-least-generic-ones/70272/2 "2017-09-18T16:25:00Z")

</div>

It’s also pretty great how the bad csrf error is an array instead of an object.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [18 Settembre 2017, 6:37pm UTC](https://meta.discourse.org/t/improve-add-friendly-json-api-error-messages-at-least-generic-ones/70272/3 "2017-09-18T18:37:44Z")

</div>

You need more specific reports of exactly what you are sending.

---

<div class="post-metadata">

### Author: ![dylanh724](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanh724/32/119642_2.png) [@dylanh724](https://meta.discourse.org/u/dylanh724)
#### Post date: [19 Settembre 2017, 1:33am UTC](https://meta.discourse.org/t/improve-add-friendly-json-api-error-messages-at-least-generic-ones/70272/4 "2017-09-19T01:33:11Z")

</div>

> [@riking](#):
>
> It’s also pretty great how the bad csrf error is an array instead of an object.

Yea it’s pretty awkward and inconsistent right now.

> [@codinghorror](#):
>
> You need more specific reports of exactly what you are sending.

In OP, I mentioned I posted to /posts – the first one I typo’d the secret. The 2nd one I left out a required field. To be specific as to exactly what I wrote:

1st post (typo key):

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/8/d893a2a85bfcda2bd0c002ac0ed9d3c0e2405676.png)

2nd post (uncheck “raw”, leaving out a required field):

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/a/dad2a4942e34430afff112155e9c1430e1e02014.png)
