# Unable to Create Index using RestHighLevelClient API, ES 7.12.1

**URL:** <https://discuss.elastic.co/t/unable-to-create-index-using-resthighlevelclient-api-es-7-12-1/296757>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [February 9, 2022, 4:31pm UTC](https://discuss.elastic.co/t/unable-to-create-index-using-resthighlevelclient-api-es-7-12-1/296757 "2022-02-09T16:31:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashishgp11](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@ashishgp11](https://discuss.elastic.co/u/ashishgp11)\
**Post date:** [February 9, 2022, 4:31pm UTC](https://discuss.elastic.co/t/unable-to-create-index-using-resthighlevelclient-api-es-7-12-1/296757/1 "2022-02-09T16:31:54Z")

</div>

```auto
Hi,
I am using `ES 7.12.1` and when I am trying to create the Index with the code getting an error:

client = new RestHighLevelClient(RestClient.builder(new HttpHost("localhost", 9200, "http")));
        CreateIndexRequest createIndexRequest = new CreateIndexRequest("my-Index");
        createIndexRequest.source("{\n" +
                " \"settings\" : {\n" +
                " \"number_of_shards\" : 1,\n" +
                " \"number_of_replicas\" : 0\n" +
                " },\n" +
                " \"mappings\" : {\n" +
                " \"properties\" : {\n" +
                " \"message\" : { \"type\" : \"text\" }\n" +
                " }\n" +
                " },\n" +
                " \"aliases\" : {\n" +
                " \"twitter_alias\" : {}\n" +
                " }\n" +
                "}", XContentType.JSON);

 CreateIndexResponse createIndexResponse = client.indices().create(createIndexRequest, RequestOptions.DEFAULT);

Below is the error:

Caused by: org.elasticsearch.client.ResponseException: method [PUT], host [http://localhost:9200], URI [/my-Index?master_timeout=30s&timeout=30s], status line [HTTP/1.1 404 Not Found]
{"statusCode":404,"error":"Not Found","message":"Not Found"}

And when I checked from Kibana UI, the Index has not been created.
```

---

<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:** [March 9, 2022, 4:32pm UTC](https://discuss.elastic.co/t/unable-to-create-index-using-resthighlevelclient-api-es-7-12-1/296757/2 "2022-03-09T16:32:11Z")

</div>

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