4

The task is to write a code that applies a sensitivity label to a document in a SharePoint Online document library without downloading the file.

I have explored the following APIs so far:

  • SharePoint REST API v1: Can be used to set a Retention label but not a Sensitivity label.
  • Microsoft Graph REST API: Can’t find any public methods for setting any labels in this API. All label-related properties seem to be read-only.
  • Microsoft Information Protection (MIP) SDK: Sensitivity labels can be applied to a local file. A stream (e.g. memory stream) is also accepted as input/output so it is possible to apply labels in memory. But it still requires downloading the file from SharePoint.

1 Answer 1

0

@P-39 Airacobra

Can be done by PowerShell script:

https://learn.microsoft.com/en-us/microsoft-365/compliance/sensitivity-labels-teams-groups-sites?view=o365-worldwide#use-powershell-to-apply-a-sensitivity-label-to-multiple-sites

But I'm looking for the same, like to apply settings using the unattended way, like REST API, saw something in Microsoft Graph API BETA: https://github.com/microsoftgraph/powershell-aad-samples/blob/master/ReassignSensitivityLabelToO365Groups.ps1 But not tested yet.

Seems found something, will look later: https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/modern-experience-site-classification

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for sharing your findings. The PowerShell examples can apply Sensitivity Labels to the whole SharePoint site, not just individual documents. The second link shows how to apply Sensitivity Labels to groups. Microsoft GRAPH is not even exposing the assignedLabels property for List Items or Documents. See the result of https://graph.microsoft.com/beta/sites/root/lists/<list id>/items/1. And I was not able to call a PATCH method to update that property. The third link is talking about site classification, not Sensitivity Labels on Documents I am afraid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.