Question

Control Room API - List roles

  • 11 August 2022
  • 2 replies
  • 62 views

Badge +5

Hi,

I wanted to list roles with filter so I wrote the parameters

but it keeps returning the failure response:

 

"Unable to locate Attribute with the the given name [countPrincipals] on this ManagedType [com.automationanywhere.common.model.Identity]"

 

It seems there's nothing wrong with countPrincipals object according to this document:

 

https://docs.automationanywhere.com/bundle/enterprise-v2019/page/enterprise-cloud/topics/control-room/control-room-api/list-roles.html/p>

 

Could you please check why it fails?

 

note: The below is what I wrote as a parameter

 

{

"sort":[],

"filter":{

"operator":"and",

"operands":[

{

"operator":"eq",

"field":"systemRole",

"value":false

},

{

"operator":"eq",

"field":"countPrincipals",

"value":1

}

]

},

"fields":[],

"page":{

"offset":0,

"length":1000

}

}


2 replies

Userlevel 4
Badge +7

Hi @Eunji Lee​ ,

 

I've tested this out from my end as well and faced the same issue.

There is a workaround, one that involves leveraging Postman's JS capabilities.

 

In Postman, you can Visualize the response by providing a skeletal HTML structure for the data to cling onto.

 

Here is a snippet of the code used in the Test Tab:

var template = `

    <table bgcolor="#FFFFFF">

        <tr>

            <th>ID</th>

            <th>Role</th>

            <th>User Count</th>

        </tr>

 

        {{#each response}}

            <tr>

                <td>{{id}}</td>

                <td>{{name}}</td>

                <td>{{countPrincipals}}</td>

            </tr>

        {{/each}}

    </table>

`;

var filteredResponse = pm.response.json().list.filter(x => x.countPrincipals===1);

 

pm.visualizer.set(template, {

    response: filteredResponse

});

 

 

And here is a screenshot of the output in the Body -> Visualize Tab:

image 

Kind Regards,

Ashwin A.K

 

Badge +5

Hi @Ashwin A.K​ ,

Thank you so much for your answer. It helped me a lot.

Reply