Pagination

The following topic provides instruction on how to paginate API output using the REST API for Oracle Enterprise Manager.

List Pagination

Most List operations paginate results. For example, results are paginated for the GET /em/api/users operation in the EM API. When you call a paginated List operation, the response body indicates additional pages of results and the API to call via the "next" resource attribute. The response body indicates previous pages of results and the API to call via the "previous" resource attribute.

Example Response for GET /em/api/users?limit=2 is shown below.

First Page

{
    "count": 2,
    "links": {
        "next": {
            "href": "/em/api/users?page=eyJsaW1pdCI6MiwiY3Vyc29yRmllbGRzIjpbeyJuYW1lIjoibmFtZSIsInZhbHVlIjoiREVTSUdORVIiLCJhc2MiOnRydWV9XSwibW92ZUZvcndhcmQiOnRydWV9"
        },
        "self": {
            "href": "/em/api/users?page=eyJsaW1pdCI6MiwibW92ZUZvcndhcmQiOnRydWV9"
        }
    },
    "items": [
        {
            "authenticationType": "Repository",
            "description": "Cloud Software Library User (Internal)",
            "isPasswordChangeAllowed": true,
            "passwordProfile": "DEFAULT",
            "id": "D27BF56E2F7A0C68E0538C104B645540",
            "name": "CLOUD_SWLIB_USER",
            "category": "Administrator",
            "externalId": "CLOUD_SWLIB_USER",
            "lifecycleStatus": "ACTIVE",
            "isLocked": false,
            "links": {
                "permissions": {
                    "href": "/em/api/users/D27BF56E2F7A0C68E0538C104B645540/permissions"
                },
                "self": {
                    "href": "/em/api/users/D27BF56E2F7A0C68E0538C104B645540"
                },
                "roleGrants": {
                    "href": "/em/api/users/D27BF56E2F7A0C68E0538C104B645540/roleGrants"
                }
            }
        },
        {
            "authenticationType": "Repository",
            "isPasswordChangeAllowed": true,
            "passwordProfile": "DEFAULT",
            "id": "D2AD0D71143B4E26E0533B8145643764",
            "name": "DESIGNER",
            "category": "Administrator",
            "externalId": "DESIGNER",
            "lifecycleStatus": "ACTIVE",
            "isLocked": false,
            "links": {
                "permissions": {
                    "href": "/em/api/users/D2AD0D71143B4E26E0533B8145643764/permissions"
                },
                "self": {
                    "href": "/em/api/users/D2AD0D71143B4E26E0533B8145643764"
                },
                "roleGrants": {
                    "href": "/em/api/users/D2AD0D71143B4E26E0533B8145643764/roleGrants"
                }
            }
        }
    ]
}

Second Page

{
    "count": 2,
    "links": {
        "next": {
            "href": "/em/api/users?page=eyJsaW1pdCI6MiwiY3Vyc29yRmllbGRzIjpbeyJuYW1lIjoibmFtZSIsInZhbHVlIjoiRU1TU0FfQURNSU4iLCJhc2MiOnRydWV9XSwibW92ZUZvcndhcmQiOnRydWV9"
        },
        "previous": {
            "href": "/em/api/users?page=eyJsaW1pdCI6MiwiY3Vyc29yRmllbGRzIjpbeyJuYW1lIjoibmFtZSIsInZhbHVlIjoiRU1DTE9VRF9BRE1JTiIsImFzYyI6ZmFsc2V9XSwibW92ZUZvcndhcmQiOmZhbHNlfQ"
        },
        "self": {
            "href": "/em/api/users?page=eyJsaW1pdCI6MiwiY3Vyc29yRmllbGRzIjpbeyJuYW1lIjoibmFtZSIsInZhbHVlIjoiREVTSUdORVIiLCJhc2MiOnRydWV9XSwibW92ZUZvcndhcmQiOnRydWV9"
        }
    },
    "items": [
        {
            "authenticationType": "Repository",
            "isPasswordChangeAllowed": true,
            "passwordProfile": "DEFAULT",
            "id": "D2AD0D71144B4E26E0533B8145643764",
            "name": "EMCLOUD_ADMIN",
            "category": "Administrator",
            "externalId": "EMCLOUD_ADMIN",
            "lifecycleStatus": "ACTIVE",
            "isLocked": false,
            "links": {
                "permissions": {
                    "href": "/em/api/users/D2AD0D71144B4E26E0533B8145643764/permissions"
                },
                "self": {
                    "href": "/em/api/users/D2AD0D71144B4E26E0533B8145643764"
                },
                "roleGrants": {
                    "href": "/em/api/users/D2AD0D71144B4E26E0533B8145643764/roleGrants"
                }
            }
        },
        {
            "authenticationType": "Repository",
            "isPasswordChangeAllowed": true,
            "passwordProfile": "DEFAULT",
            "id": "D2AD0D71144D4E26E0533B8145643764",
            "name": "EMSSA_ADMIN",
            "category": "Administrator",
            "externalId": "EMSSA_ADMIN",
            "lifecycleStatus": "ACTIVE",
            "isLocked": false,
            "links": {
                "permissions": {
                    "href": "/em/api/users/D2AD0D71144D4E26E0533B8145643764/permissions"
                },
                "self": {
                    "href": "/em/api/users/D2AD0D71144D4E26E0533B8145643764"
                },
                "roleGrants": {
                    "href": "/em/api/users/D2AD0D71144D4E26E0533B8145643764/roleGrants"
                }
            }
        }
    ]
}

Note:

Any time the next attribute appears, there are more list items to get. If the previous attribute appears, then there are previous items to get.

To get the next page of results

Make a new GET request using the URL provided in the next attribute. Repeat this process until you get a response without the next attribute. The absence of this attribute indicates that you have reached the last page of the list.

To get the previous page of results

Make a new GET request against the same URL, using the URL provided in the previous attribute. Repeat this process until you get a response without the previous attribute. The absence of this attribute indicates that you have reached the first page of the list.

To change the maximum number of results per page

In the GET request, set the "limit" query parameter to the number of items you want returned in the response. This should be done with the original request and not on any further requests to get previous or next pages of results.

Note:

The API will return no more than the number specified as limit, but might not return that exact number. For example, the result may only have 3 items in the final paginated set.

Clients should refer to the count attribute to identify the exact number of entries returned.