Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Extract each element in array as input in servicecallout policy

I have a requirement where i need to get all the user roles in my org and then get users in each role.Below is the expected response .

{ "Role": "xyz", "Users": { "a","b" }

I created a proxy with target url as management api to get all roles and added JS policy.

var userroles = []

userroles=context.getVariable("response.content");

for(var i = 0 ;i < userroles.length; i++)

{ print("userroles are " + userroles[i]) }

Now i want to use each userrole in different policy,how can that be done

Solved Solved
0 15 737
1 ACCEPTED SOLUTION

Now i want to use each userrole in different policy,how can that be done

What do you mean by this? I think you want to query the list of users for each role in the system.

That's not a good use case for Apigee, or for the JS callout. The JS callout can send an HTTP request outbound, but there are limitations. For example, there is a maximum time that a JS policy will execute.

It feels to me, that a better way to do this is just to write a script (nodejs, bash, powershell, etc) that does the work for you, and run that script.

The logic is

  • get the list of roles
  • for each role: get the users in the role

?

View solution in original post

15 REPLIES 15
Top Solution Authors