Graph API - Unable to upload the content of file when the file is protected using Sensitivity label

Sumugan Swaroop 1 Reputation point
2022-12-20T12:06:43.853+00:00

I'm trying to replace content of a file using GraphAPI to sharepoint. The file present on the sharepoint site has been encrypted by a protected sensitivity label. I've the following permissions granted for the access token.

  • Directory.ReadAll
  • Content.DelegatedReader
  • Content.DelegatedWriter
  • Content.Writer
  • user impersonation
  • Directory.ReadAll
  • Files.ReadWrite.All
  • Group.Read.All
  • Sites.ReadWrite.All
  • User.Read.All
  • UnifiedPolicy.Tenant.Read
  • UnifiedPolicy.User.Read
  • ActivityFeed.Read
  • Sites.ReadWrite.All
  • TermStore.ReadWrite.All
  • User.ReadWite.All

I'm getting the following error from the API.

{\"error\":{\"code\":\"notAllowed\",\"message\":\"This operation has been disabled by policy\",\"innerError\":{\"date\":\"2022-12-20T11:06:48\",\"request-id\":\"ce194de5-60b6-43a5-8289-85706622cfe1\",\"client-request-id\":\"ce194de5-60b6-43a5-8289-85706622cfe1\"}}}

Is there a way in Graph API to replace content for an encrypted file?

Microsoft 365 and Office SharePoint Development
{count} votes

2 answers

Sort by: Most helpful
  1. Tong Zhang_MSFT 9,251 Reputation points
    2022-12-21T07:53:24.767+00:00

    Hi @Sumugan Swaroop ,

    According to my research and testing, I can successfully use the following Graph API to replace file content when using sensitivity label:

    PUT /sites/{site-id}/drive/items/{item-id}/content  
    

    Please try again using the Graph API above. In addition, are you using Graph Explorer? If yes, try to perform this request in Postman.

    My test result:
    272816-02.png

    Hope it can help you. Thanks for your understanding.


    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.



  2. Westley Hall 6 Reputation points Microsoft Employee
    2024-03-07T21:14:07.9033333+00:00

    This may only affect the upload when the sensitivity label encrypts the file. In this case you may need to remove the label/decrypt and then upload and apply it/encrypt again.

    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.