# Elasticsearch Add a user to role-mapping

**URL:** <https://forum.opensearch.org/t/elasticsearch-add-a-user-to-role-mapping/6874>\
**Category:** Security\
**Created:** [August 27, 2021, 1:13pm UTC](https://forum.opensearch.org/t/elasticsearch-add-a-user-to-role-mapping/6874 "2021-08-27T13:13:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lokeshv1989](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@lokeshv1989](https://forum.opensearch.org/u/lokeshv1989)\
**Post date:** [August 27, 2021, 1:13pm UTC](https://forum.opensearch.org/t/elasticsearch-add-a-user-to-role-mapping/6874/1 "2021-08-27T13:13:38Z")

</div>

Hi All,  
We are trying to create user-role mapping using the open-distro api’s.

```auto
PATCH _opendistro/_security/api/rolesmapping/<role>
[
  {
    "op": "add", "path": "/users", "value": ["myuser"]
  }
]

```

But we are getting the below error while trying to execute this command,

{“statusCode”:400,“error”:“Bad Request”,“message”:“[request query.method]: Method must be one of, case insensitive [‘HEAD’, ‘GET’, ‘POST’, ‘PUT’, ‘DELETE’]. Received ‘PATCH’.”}

Can you please advise.

Regards  
Lokesh V

---

<div class="post-metadata">

**Author:** ![searchymcsearchface](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/searchymcsearchface/32/868_2.png) [@searchymcsearchface](https://forum.opensearch.org/u/searchymcsearchface)\
**Post date:** [August 27, 2021, 1:19pm UTC](https://forum.opensearch.org/t/elasticsearch-add-a-user-to-role-mapping/6874/2 "2021-08-27T13:19:40Z")

</div>

This is related to the security plugin, so I’m going to move this to the correct category.

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/10363_2.png) [@pablo](https://forum.opensearch.org/u/pablo)\
**Post date:** [August 27, 2021, 1:46pm UTC](https://forum.opensearch.org/t/elasticsearch-add-a-user-to-role-mapping/6874/3 "2021-08-27T13:46:24Z")

</div>

Hi @lokeshv1989

You need to enable PATCH API in elasticsearch.yml

 ![image](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/3cc34f6c2ba724dce8af2a445dbc57179471e26a.png)

> **[API](https://opendistro.github.io/for-elasticsearch-docs/docs/security/access-control/api/)**
>
> Documentation for Open Distro, the community-driven, 100% open source distribution of Elasticsearch OSS with advanced security, alerting, deep performance analysis, and more.

---

<div class="post-metadata">

**Author:** ![lokeshv1989](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@lokeshv1989](https://forum.opensearch.org/u/lokeshv1989)\
**Post date:** [August 30, 2021, 12:55pm UTC](https://forum.opensearch.org/t/elasticsearch-add-a-user-to-role-mapping/6874/4 "2021-08-30T12:55:34Z")

</div>

Thank you @pablo and @searchymcsearchface  
However I am able to see that we will not be able to modify elasticsearch.yml in AWS managed ElasticSearch clusters.

Can you then point me how to make this edit using any API or something in my case where I am having AWS managed ElasticSearch cluster.

Regards  
Lokesh V

---

<div class="post-metadata">

**Author:** ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/10363_2.png) [@pablo](https://forum.opensearch.org/u/pablo)\
**Post date:** [August 31, 2021, 9:01am UTC](https://forum.opensearch.org/t/elasticsearch-add-a-user-to-role-mapping/6874/5 "2021-08-31T09:01:11Z")

</div>

Hi @lokeshv1989

As per documentation, the PATCH API is enabled through the elasticsearch.yml file only. There is no API to enable PATCH in the running cluster.  
Maybe you should try to ask your ES provider (AWS) to include the PATCH API in your cluster configuration.

---

<div class="post-metadata">

**Author:** ![lokeshv1989](https://avatars.discourse-cdn.com/v4/letter/l/d78d45/32.png) [@lokeshv1989](https://forum.opensearch.org/u/lokeshv1989)\
**Post date:** [August 31, 2021, 10:11am UTC](https://forum.opensearch.org/t/elasticsearch-add-a-user-to-role-mapping/6874/6 "2021-08-31T10:11:07Z")

</div>

Thank you @pablo for your reply
