Skip to content

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.

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 the role access. The invitation requires signing in with that account to open the file, and an email is sent if notify is true. scope is not used in this mode.
  • If you do not give email, a link is created; scope defines 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 role and scope for 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 if notify is true).
ParameterTypeDefaultDescription
idstring—ID of the file or folder.
ParameterTypeDefaultDescription
sessionZoanMicrosoftFilesSession—Connect session. Inherited inside Connect’s body.
rolestring"view"Access level: view (view only) or edit (view and edit).
scopestring"organization"Link scope (when there is no email): organization (people in the organization) or anonymous (anyone with the link).
emailstring—Email of the person to invite. If set, invites instead of creating a link.
notifybooltrueSend the invitation email (only with email).

Returns a Dictionary<string,object> whose shape depends on the mode:

ModeKeys
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.

MessageCause 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.
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"]