# Javascript Client security.getRole returning invalid JSON

**URL:** <https://discuss.elastic.co/t/javascript-client-security-getrole-returning-invalid-json/205522>\
**Category:** Elasticsearch\
**Created:** [October 28, 2019, 5:08pm UTC](https://discuss.elastic.co/t/javascript-client-security-getrole-returning-invalid-json/205522 "2019-10-28T17:08:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmarooney](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mmarooney](https://discuss.elastic.co/u/mmarooney)\
**Post date:** [October 28, 2019, 5:08pm UTC](https://discuss.elastic.co/t/javascript-client-security-getrole-returning-invalid-json/205522/1 "2019-10-28T17:08:14Z")

</div>

We are experiencing a strange issue with the javascript client. When calling client.security.getRole() we're seeing JSON formatted result like below:

```
await this.client.security.getRole({name: 'test-role-2'})
                .then(res => {
                  var result=res.body;
                    console.log(res.body);
                   
                    })
                .catch(error => {
                  console.log(error);
                 
                });

{ 'test-role-2':
   { cluster: [],
     indices: [],
     applications: [],
     run_as: ['baldy'],
     metadata: {},
     transient_metadata: { enabled: true } } }

```

The problem is the single-quoted key for the role name. JSON keys should be double-quoted, or have no quotes.

When executing the following get command in Kibana, the role returns correctly.

`GET _security/role/test-role-2`

```
{
  "test-role-2" : {
    "cluster" : [],
    "indices" : [],
    "applications" : [],
    "run_as" : [
      "baldy"
    ],
    "metadata" : { },
    "transient_metadata" : {
      "enabled" : true
    }
  }
}

```

This behavior only seems to occur on roles we create. The existing system roles return correctly through the client security.getRole().

We've tried creating though the Kibana management screens, Posting to the elasticsearch api directly, using a rest client, and using the javascript client, to no avail.

Does anyone know why this might be happening?

Thank you,

Matt

---

<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:** [November 25, 2019, 5:08pm UTC](https://discuss.elastic.co/t/javascript-client-security-getrole-returning-invalid-json/205522/2 "2019-11-25T17:08:21Z")

</div>

Closed on November 25, 2019, 5:08pm UTC

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