Creating a Dedicated OneDrive Folder For My Web App

Rio Lukman Tawekal 0 Reputation points
2024-07-29T06:28:00.6233333+00:00

I am building a formal mailing web application for my internal company. Is it possible to create a dedicated folder in my OneDrive to upload created Word documents, which can be shared with specified users in my organization for editing or viewing through the Microsoft Graph API?

Word
Word
A family of Microsoft word processing software products for creating web, email, and print documents.
887 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,343 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,160 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,875 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Hitesh Pachipulusu - MSFT 3,235 Reputation points Microsoft Vendor
    2024-07-29T08:40:37.73+00:00

    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:

    1. 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.
    2. 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
    3. 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
    4. 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".


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.