How to Fetch Sensitivity Labels for Files in OneDrive/SharePoint and Outlook Emails
I am having difficulty fetching the sensitivity labels for files stored in Office applications like Word and Outlook emails.
For Word: I attempted to use the endpoint https://graph.microsoft.com/v1.0/sites/{site-id}/drive/items/{item-id}/extractSensitivityLabels, but it returns a 404 error, despite the sensitivity label being applied to the document, which is visible when the document is opened.
For Emails: I used the endpoint https://graph.microsoft.com/v1.0/me/messages/{message-id}, but it does not provide any information regarding the sensitivity label. The email I was fetching was sent from another domain where Purview was enabled, and the email was marked with a sensitivity label before it was sent. I have verified that the information exists in the email's internet headers.
I consider that if there were any rights issues, there should have been an insufficient privileges error. I have provided the InformationProtectionPolicy.Read permission to my Azure app, so I believe the rights are set correctly.
Can anyone provide guidance on how to retrieve the sensitivity labels and suggest the best methods to do so?
Best Regards,
Kanwal Singh