Skip to main content
Navigator | Tier 3
August 11, 2022
Question

Control Room API - List roles

  • August 11, 2022
  • 2 replies
  • 214 views

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

    Ashwin A.K
    Navigator | Tier 3
    August 19, 2022

    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

     

    Blogs at TheCodingTheory - https://www.thecodingtheory.com
    soharuAuthor
    Navigator | Tier 3
    September 5, 2022

    Hi @Ashwin A.K​ ,

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