# GET /u/by-external/{id}.json returns HTML on 404

**URL:** <https://meta.discourse.org/t/get-u-by-external-id-json-returns-html-on-404/60437>\
**Category:** Bug\
**Created:** [April 4, 2017, 6:39pm UTC](https://meta.discourse.org/t/get-u-by-external-id-json-returns-html-on-404/60437 "2017-04-04T18:39:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vvanpo](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vvanpo/32/114112_2.png) [@vvanpo](https://meta.discourse.org/u/vvanpo)\
**Post date:** [April 4, 2017, 6:39pm UTC](https://meta.discourse.org/t/get-u-by-external-id-json-returns-html-on-404/60437/1 "2017-04-04T18:39:49Z")

</div>

The 404 response for `/u/{username}.json` returns JSON as expected:

```
{"errors":["The requested URL or resource could not be found."],"error_type":"not_found"}

```

However, `/u/by-external/{external_id}.json` doesn’t have the same behaviour. It returns JSON on success, but HTML on 404 (and I would assume for other errors as well), confusing my JSON parser.

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [April 4, 2017, 7:22pm UTC](https://meta.discourse.org/t/get-u-by-external-id-json-returns-html-on-404/60437/2 "2017-04-04T19:22:20Z")

</div>

@eviltrout perhaps this is one route that was missed in the rename?

---

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [April 4, 2017, 8:23pm UTC](https://meta.discourse.org/t/get-u-by-external-id-json-returns-html-on-404/60437/3 "2017-04-04T20:23:24Z")

</div>

This is unrelated to the path change – `by-external` needs some hacks to recognize the format which `NotFound` was not respecting.

[https://github.com/discourse/discourse/commit/3839206317bc78efd9f4872776d95c6a380f7323](https://github.com/discourse/discourse/commit/3839206317bc78efd9f4872776d95c6a380f7323)

(long term we should probably figure out a nicer way around those hacks)

---

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [April 4, 2017, 8:50pm UTC](https://meta.discourse.org/t/get-u-by-external-id-json-returns-html-on-404/60437/4 "2017-04-04T20:50:34Z")

</div>


