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.