PrashRV
(Prashanth RV)
September 16, 2024, 1:26pm
1
Hi,
someomne help me on how to access the Offset and Limit variables dynamically on account aggregation, as i trying to implement pagination for accounts, offset value is not accessable i guess.
below is the error i see when i run account aggregation
sailpoint.connector.ConnectorException: Url: Url/v2/users?startIndex=”%20$offset$%20“&count=100”, Message: 404 : Not Found, HTTP Error Code: 404
Thanks
Prashanth
Hey Prakash !
The following is the similar code for aggregation of accounts .
String getAccounts = "https://"+tenantId+".api.identitynow-demo.com/beta/identities?count=true";
Map headers = new HashMap();
headers.put("Authorization","Bearer "+accessDetails);
headers.put("Content-Type","application/json");
List<String> statuses = new ArrayList<String>();
statuses.add("2**");
String response = restClient.executeGet(getAccounts,headers,statuses);
Map responseHeaders = restClient.getResponseHeaders();
int count = Integer.parseInt(responseHeaders.get("X-Total-Count"));
log.info(count);
int iterations = count/250;
int offset =0;
for(int i=0;i<iterations;i++)
{
String offset1 = String.valueOf(offset);
String getAccounts = "https://url?sorters=name&count=true&offset="+offset1;
offset = Integer.parseInt(offset1);
offset = (i+1)*250;
Map headers = new HashMap();
headers.put("Authorization","Bearer "+accessDetails);
headers.put("Content-Type","application/json");
List<String> statuses = new ArrayList<String>();
statuses.add("2**");
String response = restClient.executeGet(getAccounts,headers,statuses);
log.info("++++++++After Execution:");
Object result = JsonUtil.parseJson(response);
Object temp = JsonUtil.parseJson(response);
result.clear();
for(int i=0;i<temp.size();i++)
{
Map ele = temp.get(i);
Map attributes = ele.get("attributes");
String uid = attributes.get("uid");
String name = ele.get("name");
String email = ele.get("emailAddress");
ele.clear();
ele.put("name",name);
ele.put("email",email);
ele.put("uid",uid);
result.add(ele);
}
log.info("Processsed Response*******************************************");
processedResponseObject.addAll(result);
log.info(processedResponseObject);
}
PrashRV
(Prashanth RV)
September 16, 2024, 1:40pm
3
Hey Siddarth,
but i need it through pagination tab not through rule, do you have anything related to that…?
Thanks
Prashanth
Hi @PrashRV
Greetings of the Day!
please check the below pagination code
$limit$ = 100
TERMINATE_IF $response.totalCount$ < $response.pageNo$ * $response.pageSize$
$offset$ = $offset$ + $limit$
$endpoint.fullUrl$ = $application.baseUrl$ + “/users?startIndex=”+$offset$+“&count=100”
Thank You
PrashRV
(Prashanth RV)
September 18, 2024, 10:14am
5
No Mahesh, same error I am getting, it is not able to replace the offset in the link
Thanks
Prashanth
pablonovoa
(Pablo Novoa Lopez)
September 18, 2024, 10:25am
6
Hello Prasanth,
Could you try using another name instead of offset? it can be a reserved word and that could be the reason
Regards,
Pablo
Hi @PrashRV ,
Good Day!
please refer the below link for pagination
1 Like
Based on your error the “+” in the URL is getting escaped rather than doing string addition.
This pagination code should work for you:
$limit$ = 100
TERMINATE_IF ( $NO_RECORDS$ == TRUE )
$offset$ = $offset$ + $limit$
$endpoint.fullUrl$ = $application.baseUrl$ + "/users?count=100&startIndex=" + $offset$
PrashRV
(Prashanth RV)
September 19, 2024, 6:49am
9
Thanks Zeel, worked for me
1 Like
system
(system)
Closed
November 18, 2024, 6:50am
10
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.