How to use Microsoft Graph API add password for OneDrive online file.

Scorpio 20 Reputation points
2024-01-19T05:12:52.73+00:00

I user Microsoft Graph API to upload file to OneDrive, require add password.

Microsoft 365 and Office | OneDrive | For business | Windows
Microsoft Security | Microsoft Graph
0 comments No comments

Answer accepted by question author
Anonymous
2024-01-22T09:21:23.03+00:00

Hi @Scorpio,

Microsoft Graph does not seem to be able to directly add passwords to files on OneDrive, but you can add access passwords to shared file links:

POST /me/drive/items/{item-id}/createLink
Content-type: application/json

{
  "type": "view",
  "password": "ThisIsMyPrivatePassword",
  "scope": "anonymous",
  "retainInheritedPermissions": false
}

For more detail, you can refer to this document: Create a sharing link for a DriveItem. If you receive error code sharingDisabled, you can refer to this document to open the corresponding permissions (if you are an administrator): Sharing errors in SharePoint and OneDrive. Hope this helps. If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

Was this answer helpful?


1 additional answer

Sort by: Most helpful
  1. Scorpio 20 Reputation points
    2024-01-22T09:24:28.6566667+00:00

    Thanks, I have solved the problem.

    Was this answer helpful?

    0 comments No comments

Your answer

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