OneDrive/SharePoint — Share
OneDrive/SharePoint — Share
Section titled “OneDrive/SharePoint — Share”Type: msfiles-share · Package: OneDrive / SharePoint v1.0.5 · Output: Dictionary<string,object>
Shares a file or folder in two ways: by creating a sharing link or by inviting a user by email. In both cases you choose the access level (view or edit), so the robot delivers documents without anyone sharing them by hand.
How it works
Section titled “How it works”It works on the session created with OneDrive/SharePoint — Connect. Pass it in the session parameter, or place this activity inside the body of Connect to inherit it automatically.
- If you give
email, that person is invited with theroleaccess. The invitation requires signing in with that account to open the file, and an email is sent ifnotifyistrue.scopeis not used in this mode. - If you do not give
email, a link is created;scopedefines whether it works only for people in the organization (organization) or for anyone who has it (anonymous).
Keep in mind:
- The organization’s sharing policies prevail: if anonymous links or external sharing are disabled in Microsoft 365, the activity fails.
- Creating a link with the same
roleandscopefor the same file returns the existing link, so it is safe to repeat. Inviting the same person again updates their permission (and may send the email again ifnotifyistrue).
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | — | ID of the file or folder. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanMicrosoftFilesSession | — | Connect session. Inherited inside Connect’s body. |
role | string | "view" | Access level: view (view only) or edit (view and edit). |
scope | string | "organization" | Link scope (when there is no email): organization (people in the organization) or anonymous (anyone with the link). |
email | string | — | Email of the person to invite. If set, invites instead of creating a link. |
notify | bool | true | Send the invitation email (only with email). |
Output
Section titled “Output”Returns a Dictionary<string,object> whose shape depends on the mode:
| Mode | Keys |
|---|---|
Link (no email) | link (sharing URL), role, scope. |
Invitation (with email) | permissionId (ID of the granted permission), role, email. |
Use shared["link"] to send the link by email or store it in a report.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
No OneDrive/SharePoint session available. Provide 'session' from an msfiles-connect activity, or place this activity inside the Connect activity's body so the session is inherited automatically. | The activity is outside Connect’s body and did not receive session. Place it inside the body or pass session = session. |
'id' is required. | id is empty or its expression returned null. |
itemNotFound (Microsoft Graph, 404) | There is no item with that ID in the session’s drive. |
accessDenied (Microsoft Graph, 403) | The account cannot share that item, or the organization’s policy does not allow that link type (for example anonymous) or inviting external people. Use scope = organization or ask your Microsoft 365 administrator for the change. |
invalidRequest (Microsoft Graph, 400) | The email address is not valid. |
Example
Section titled “Example”OneDrive/SharePoint — Connect credential = credential("m365-operations") └─ body: OneDrive/SharePoint — Upload path = reportPath destination = "Reports/monthly.pdf" → output: uploaded OneDrive/SharePoint — Share id = uploaded["id"] scope = organization role = view → output: shared Log message = "Report link: " + shared["link"]Related activities
Section titled “Related activities”- OneDrive/SharePoint — Upload — upload the file to share.
- OneDrive/SharePoint — Get info — get the file’s link.
- OneDrive/SharePoint — Create folder — share a whole folder.
- All OneDrive / SharePoint activities