# Example of error response for POST \_aliases API

**URL:** https://discuss.elastic.co/t/example-of-error-response-for-post-aliases-api/340917
**Category:** Elasticsearch
**Created:** [August 16, 2023, 12:32pm UTC](https://discuss.elastic.co/t/example-of-error-response-for-post-aliases-api/340917 "2023-08-16T12:32:04Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Tomas\_Hanus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomas_hanus/32/124662_2.png) [@Tomas\_Hanus](https://discuss.elastic.co/u/Tomas_Hanus)
#### Post date: [August 16, 2023, 12:32pm UTC](https://discuss.elastic.co/t/example-of-error-response-for-post-aliases-api/340917/1 "2023-08-16T12:32:04Z")

</div>

Hi,

we are using 8.x JAVA client to communicate with Elasticsearch. In case of trying to handle unexpected error for updating aliases the documentation is saying nothing - [Aliases API | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html).

The Java API of the client is saying for **acknowledged** field of `co.elastic.clients.elasticsearch.indices.UpdateAliasesResponse` class, that:

> Required - For a successful response, this value is always true. On failure, an exception is returned instead.

But what is it exactly? For example if I try to update alias for non existing index, the 404 is returned. The very similar behaviour for alias name. But is there another scenario when Elasticsearch can answer differently? 500 or something else, and with which payload?

I would like to write test for this scenario but I don't know how I should simulate response of Elasticsearch.

Tomas

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [August 16, 2023, 1:04pm UTC](https://discuss.elastic.co/t/example-of-error-response-for-post-aliases-api/340917/2 "2023-08-16T13:04:31Z")

</div>

All exception responses have the same overall shape, which looks like this:

```auto
< HTTP/1.1 503 Service Unavailable
< X-elastic-product: Elasticsearch
< content-type: application/json
< content-encoding: gzip
< content-length: 145
<
{
  "error" : {
    "root_cause" : [
      {
        "type" : "master_not_discovered_exception",
        "reason" : null
      }
    ],
    "type" : "master_not_discovered_exception",
    "reason" : null
  },
  "status" : 503
}

```

---

<div class="post-metadata">

### Author: ![Tomas\_Hanus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomas_hanus/32/124662_2.png) [@Tomas\_Hanus](https://discuss.elastic.co/u/Tomas_Hanus)
#### Post date: [August 17, 2023, 7:41am UTC](https://discuss.elastic.co/t/example-of-error-response-for-post-aliases-api/340917/3 "2023-08-17T07:41:14Z")

</div>

Hi David, thank you very much for your answer ;).

---

<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: [September 14, 2023, 7:41am UTC](https://discuss.elastic.co/t/example-of-error-response-for-post-aliases-api/340917/4 "2023-09-14T07:41:51Z")

</div>

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