# Determine if Get Doc response is success

**URL:** <https://discuss.elastic.co/t/determine-if-get-doc-response-is-success/71912>\
**Category:** Elasticsearch\
**Created:** [January 17, 2017, 9:33pm UTC](https://discuss.elastic.co/t/determine-if-get-doc-response-is-success/71912 "2017-01-17T21:33:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KodrAus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kodraus/32/22798_2.png) [@KodrAus](https://discuss.elastic.co/u/KodrAus)\
**Post date:** [January 17, 2017, 9:33pm UTC](https://discuss.elastic.co/t/determine-if-get-doc-response-is-success/71912/1 "2017-01-17T21:33:06Z")

</div>

Hi all!

Say I send a GET to:

```auto
/index/type/id

```

Where one of `index`, `type` and `id` doesn't exist. So it's going to `404`.

The problem is if the index doesn't exist then you get an exception response. If it's something else then you get a hit response with `found: false`.

This is a bit of a problem from a client perspective because I really don't want to have inspect the response body to determine whay kind of data it is before parsing it into a particular shape. That means buffering it out and poking around before going back and parsing it. Sounds kind of brittle.

I've noticed there are a couple of headers on the exception response. Checking if those exist to determine if it's an index exception would do, it's still a bit brittle, but better than having to run over the response multiple times.

It'd be nice if all responses to a particular endpoint with a particular status code had a similar shape.

How do other REST API clients deal with this?

EDIT: Upon reflection I think is is less of an issue then I made it out to be 5 minutes ago. You know from the status code that it's a 'non success', so having a slower parser to figure out why should be ok, and not affect the performance of the happy path so much.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 14, 2017, 9:33pm UTC](https://discuss.elastic.co/t/determine-if-get-doc-response-is-success/71912/2 "2017-02-14T21:33:10Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
