Using a nested REST API in combination with pagination (using the Graph API)

Hello everyone,


I hope someone can help me with this.

I am working on getting Azure AD Groups via the Graph API and then retrieving the members through a nested API call.

I saw a post concerning a nested REST API call together with pagination in which one of the commenters (Gijs) had the exact same API which I am also using (commented by Gijs):

However, the suggestion didn't work for my use-case as it only ‘expanded’ the nested values, but didn't paginate. I only got the members of the first 100 groups.

I used the RSD-file from the commenter Gijs with the addition of two points:

  • two additional rows to enable pagination;
  • [memberout.userPrincipalName| allownull()] instead of [memberout.userPrincipalName] as I was getting a [500] error with this specific attribute.

I've made them bold in the code down below.

Would someone be able to give me some pointers to what I'm missing in the RSD file to enable pagination on this nested REST API call?

Kind regards,
Johnny Yang

This is what I have written in the RSD file:


<api:script xmlns:api="" xmlns:xs="">

  <!-- See Column Definitions to specify column behavior and use XPaths to extract column values from JSON. -->
  <api:info title="GraphGroupMembers_Test2" desc="Generated schema file." xmlns:other="">
    <!-- You can modify the name, type, and column size here. -->
    <attr name="GroupId"           xs:type="string"  readonly="false" other:xPath="groupId"            />
    <attr name="GroupDisplayName"  xs:type="string"  readonly="false" other:xPath="groupDisplayName"   />
    <attr name="GroupDescription"  xs:type="string"  readonly="false" other:xPath="groupDescription"   />
    <attr name="UserId"            xs:type="string"  readonly="false" other:xPath="userId"             />
    <attr name="UserDisplayName"   xs:type="string"  readonly="false" other:xPath="userDisplayName"    />
    <attr name="UserPrincipalName" xs:type="string"  readonly="false" other:xPath="userPrincipalName"  />
    <!-- Attributes are used for passing to child API call -->
    <attr name="Id"                xs:type="string"  readonly="false" other:xPath="id"                 />
    <attr name="DisplayName"       xs:type="string"  readonly="false" other:xPath="displayName"        />
    <attr name="Description"       xs:type="string"  readonly="false" other:xPath="description"        />

  <api:set attr="groupin.DataModel" value="DOCUMENT" />
  <api:set attr="groupin.JSONPath" value="/value" />
  <api:set attr="groupin.URITemplate" value="$select=id,displayName,description" />
  <api:set attr="groupin.pageurlpath" value="/\[@odata.nextLink\]"     />        
  <api:set attr="groupin.RepeatElement" value="/value/"                 />     
 <api:set attr="groupin.ElementMapPath#" value="/value/id" />
  <api:set attr="groupin.ElementMapName#" value="group_id" />
  <api:set attr="groupin.EnablePaging" value="TRUE" />
  <api:set attr="memberin.DataModel" value="DOCUMENT" />
  <api:set attr="memberin.EnablePaging" value="TRUE" />
  <api:set attr="memberin.JSONPath" value="/value" />
  <api:set attr="memberin.URITemplate" value="{groupId}/members?$select=id,displayName,userPrincipalName" />
  <!--api:set attr="JSONPath" value="" /-->

  <!-- The GET method corresponds to SELECT. Here you can override the default processing of the SELECT statement. The results of processing are pushed to the schema's output. See SELECT Execution for more information. -->
  <api:script method="GET">
    <api:set attr="groupin.URI" value="[groupin.URITemplate]" />
    <!-- Get the groups -->
    <api:call op="jsonproviderGet" in="groupin" out="groupout">
      <api:set attr="memberin.groupId" value="[]" />
      <api:set attr="memberin.groupDisplayName" value="[groupout.displayName | allownull()]" />
      <api:set attr="memberin.groupDescription" value="[groupout.description | allownull()]" />
      <api:set attr="memberin.URI" value="[memberin.URITemplate | replace('{groupId}', [memberin.groupId])]" />
      <!-- Get the members of the group -->
      <api:call op="jsonproviderGet" in="memberin" out="memberout">
        <api:set attr="out.userId" value="[]" />
        <api:set attr="out.userDisplayName" value="[memberout.displayName]" />
        <api:set attr="out.userPrincipalName" value="[memberout.userPrincipalName| allownull()]" />
        <api:set attr="out.groupId" value="[memberin.groupId | allownull()]" />
        <api:set attr="out.groupDisplayName" value="[memberin.groupDisplayName | allownull()]" />
        <api:set attr="out.groupDescription" value="[memberin.groupDescription | allownull()]" />
        <api:push item="out"/>



0 replies

Be the first to reply!