Determine if Get Doc response is success

Hi all!

Say I send a GET to:

/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.

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