# Elasticsearch cloud returning errors on each query

**URL:** https://discuss.elastic.co/t/elasticsearch-cloud-returning-errors-on-each-query/301331
**Category:** Elasticsearch
**Created:** [April 1, 2022, 1:58pm UTC](https://discuss.elastic.co/t/elasticsearch-cloud-returning-errors-on-each-query/301331 "2022-04-01T13:58:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Munashe\_komichi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/munashe_komichi/32/101160_2.png) [@Munashe\_komichi](https://discuss.elastic.co/u/Munashe_komichi)
#### Post date: [April 1, 2022, 1:58pm UTC](https://discuss.elastic.co/t/elasticsearch-cloud-returning-errors-on-each-query/301331/1 "2022-04-01T13:58:41Z")

</div>

Trying to run queries with Elasticsearch but getting errors, help would be appreciated!

```auto

elasticsearch.exceptions.AuthorizationException: AuthorizationException(403, 'security_exception', 'action [indices:data/write/index] is unauthorized for API key id [aURW5X8BEbj8_1N8flEI] of user [elastic-userconsole-proxy], this action is granted by the index privileges [create_doc,create,index,write,all]')

```

Tried using basic\_auth for connecting but it wasnt working, http\_auth has been deprecated so the only solution left was to use api keys. Connecting is succesfull but queries are not running

Connection code below

```auto
from elasticsearch import Elasticsearch
from configparser import ConfigParser

config = ConfigParser()
config.read('connection.ini')

es = Elasticsearch(
    cloud_id=config['ELASTIC']['CLOUD_ID'],
    api_key=(config['ELASTIC']['API_ID'], config['ELASTIC']['API_KEY'])
)

def check_connection():
    if es.ping:
        return print(True)
    else:
        return print(False)

# check_connection()
print(es.info())

```

Query code below

```auto
def insert_query(reserved: str, name: str, address: str, group: str, email: str, rarity: int):
    es.index(
        index=reserved,
        document={
            'name': name,
            'address': address,
            'group': group,
            'email': email,
            'rarity': rarity
        }
    )

```

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [April 4, 2022, 12:36am UTC](https://discuss.elastic.co/t/elasticsearch-cloud-returning-errors-on-each-query/301331/2 "2022-04-04T00:36:49Z")

</div>

> [@Munashe\_komichi](#):
>
> `action [indices:data/write/index] is unauthorized for API key id [aURW5X8BEbj8_1N8flEI] of user [elastic-userconsole-proxy], this action is granted by the index privileges [create_doc,create,index,write,all]`

Did you check that?

---

<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: [April 18, 2022, 12:37am UTC](https://discuss.elastic.co/t/elasticsearch-cloud-returning-errors-on-each-query/301331/3 "2022-04-18T00:37:22Z")

</div>

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