Hello @Rio Lukman Tawekal ,
Thank you for contacting Microsoft Support!
Yes, you can create a dedicated folder in your OneDrive and share it with specified users using the Microsoft Graph API. Here’s a high-level overview of how you can achieve this:
- Create a Folder: You can create a new folder in OneDrive using the Microsoft Graph API. Here’s an example of how to do this with a POST request:
POST /me/drive/root/children
Content-Type: application/json
{
"name": "New Folder",
"folder": { },
"@microsoft.graph.conflictBehavior": "rename"
}
This request will create a new folder named “New Folder” in the root directory of your OneDrive. https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_post_children?view=odsp-graph-online. - Upload Word Documents: Once the folder is created, you can upload Word documents to this folder. You can use a PUT request to upload a file:
PUT /me/drive/items/{parent-item-id}:/{filename}:/content
Content-Type: application/octet-stream
{file-content}
Replace{parent-item-id}
with the ID of the folder you created and{filename}
with the name of the file you are uploading. https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online - Share the Folder: To share the folder with specified users, you can use the sharing API. Here’s an example of how to create a sharing link:
POST /me/drive/items/{item-id}/createLink
Content-Type: application/json
{
"type": "edit", // or "view"
"scope": "organization"
}
This will create a sharing link that you can send to users within your organization. https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_post_children?view=odsp-graph-online - Assign Permissions: You can also assign specific permissions to users:
POST /me/drive/items/{item-id}/permissions
Content-Type: application/json
{
"roles": ["write"], // or "read"
"grantee": {
"user": {
"email": "user@example.com"
}
}
}
Replace{item-id}
with the ID of the folder and"user@example.com"
with the email of the user you want to share the folder with.
These steps should help you set up a dedicated folder in OneDrive, upload Word documents, and share them with specified users for editing or viewing.
Hope this helps.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".