Microsoft Graph Retention Labels

Liam Cleary (MVP Alumni, MCT) 0 Reputation points
2025-02-19T20:52:01.65+00:00

Hi,

When I call https://graph.microsoft.com/beta/security/labels/retentionLabels, it only returns the first 100 labels. It then provides paging with a subsequent link object in the JSON. However, that link fails every time. I cannot use the standard $filter, $search, $skip, $select. I can only get the first 100 and do nothing else. In the tenant, there are 207 retention labels. For example, if I execute https://graph.microsoft.com/beta/security/labels/retentionLabels?$select=id, it returns this: "The query specified in the URI is invalid. Query option 'Select' is not allowed. To allow it, set the 'AllowedQueryOptions' property on EnableQueryAttribute or QueryValidationSettings." There seems to be no way of receiving them this way. Will this work, or is there a different way of doing it?

Liam

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,108 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Yakun Huang-MSFT 10,095 Reputation points Microsoft Vendor
    2025-02-20T01:38:33.61+00:00

    Hello Liam Cleary (MVP Alumni, MCT),

    Thank you for reaching out to Microsoft Support!

    The Graph API automatically paginates retentionLabels when they are listed, and when you visit the next page, you need to take the request header with you:

    Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik5HVEZ2ZEstZnl0aEV1Q...

    According to the documentation, since beta is a test release and is not stable, it is recommended that you use version v1.0.

    User's image

    Also, according to the documentation, this endpoint only supports expand query parameters, so an error occurs when you use other query parameters.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.


  2. Liam Cleary (MVP Alumni, MCT) 0 Reputation points
    2025-02-20T12:44:15.87+00:00

    Thank you.

    I can see the pagination in the results, but it fails when manually clicking the pagination link in Graph Explorer, PostMan, or even using code. When I call the initial request, it get this link back in the results:

    User's image

    When I navigate to this, including the Bearer token, this is what happens:

    User's image

    This happens every time, whether it is v1.0 or Beta Endpoint. I then get the normal errors for any specific OData parameters that are not supported.

    https://graph.microsoft.com/beta/security/labels/retentionLabels?$top=300

    This returns this error:

    User's image

    I hope this explains a bit more what the issue is.

    Thanks. Liam

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.