Pulling Sensitivity Labels by Columns names in OneDrive/SharePoint

Ivan Zeljkovic 80 Reputation points
2024-07-08T20:24:54.7233333+00:00

Hi there, we're hoping to collect sensitivity label names without the use of the extractSensitivityLabels API as it wouldn't be feasible on large environments.

As an alternative, we're attempting the following:

https://graph.microsoft.com/v1.0/sites/{site-id}/drive/list/items?expand=driveItem,fields&top=999

by expanding fields, we're capable of catching the Sensitivity Label display names here:

"fields": {
                "ContentType": "Document",
                "EditorLookupId": "52",
                "_CheckinComment": "",
                "LinkFilenameNoMenu": "ignore_me.docx",
                "LinkFilename": "ignore_me.docx",
                "DocIcon": "docx",
                "FileSizeDisplay": "34052",
                "ItemChildCount": "0",
                "FolderChildCount": "0",
                "_ComplianceFlags": "",
                "_ComplianceTag": "",
                "_ComplianceTagWrittenTime": "",
                "_ComplianceTagUserId": "",
                "_CommentCount": "",
                "_LikeCount": "",
                "_DisplayName": "Intellectual Property",
                "Edit": "0",
            }

My question is: would it be correct to expect the _DisplayName field to always represent the collection of Sensitivity Labels? The field seems to remain empty for files which do not have labels applied to them. I couldn't find documentation regarding this, so I'd appreciate any help.

Thank you for your time.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,005 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,110 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,685 questions
0 comments No comments
{count} votes

Accepted answer
  1. Xyza Xue_MSFT 24,716 Reputation points Microsoft Vendor
    2024-07-09T03:00:51.72+00:00

    Hi @Ivan Zeljkovic ,

    Thank you for posting in this community.

    You're right! The field(_DisplayName) in the property of the response from the Microsoft Graph API represents the display name of the sensitivity label applied to the file. If a file doesn’t have a sensitivity label applied, the field will remain empty (as you’ve observed). Only files with an assigned sensitivity label will populate this field with the label’s display name.


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

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.