OneDrive/SharePoint — Connect
OneDrive/SharePoint — Connect
Section titled “OneDrive/SharePoint — Connect”Type: msfiles-connect · Package: OneDrive / SharePoint v1.0.5 · Output: ZoanMicrosoftFilesSession
Opens an authenticated session with OneDrive or SharePoint through Microsoft Graph. It is the starting point of the package: the file activities (upload, download, list, move…) and the SharePoint list activities work on this session.
How it works
Section titled “How it works”It authenticates with a Microsoft 365 OAuth connection from Zoan Cloud and resolves the drive to work on. It can be used in two ways:
- With
body: the activities you place inside inherit the session automatically; when the block ends, it closes on its own (also if an activity in the block fails). - Without
body: it returns the session as output; store it in a variable, pass it throughsessionto the other activities and close it with Close.
Step by step:
- It gets the connection’s token. The session keeps using that token until it is closed (it is not renewed); for processes longer than an hour, open the session in blocks.
- If you do not give
driveId, it asks Microsoft Graph for the default drive: the OneDrive of the connection’s account or, withmailbox, that user’s. If you givedriveId, it is used as is, without checking it. - It keeps
siteIdfor the list activities. It is not validated here: a wrong site shows up as an error in the first list activity.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
credential | credential | — | Zoan Cloud Microsoft 365 OAuth connection, referenced by its key name: credential("m365-operations"). |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
mailbox | string | — | User (email or UPN) whose OneDrive is used when no driveId is given. Omit it to use the account that authorized the connection. Required if the credential holds an app-only token. |
driveId | string | — | ID of the files drive. When omitted, the OneDrive of the account (or of mailbox). Use the ID of a SharePoint document library to work with its files. |
siteId | string | — | SharePoint site ID (contoso.sharepoint.com,<guid>,<guid>). Only the list activities need it. |
Sub-flows
Section titled “Sub-flows”body optional
Section titled “body optional”Activities to run inside the session. They inherit the session automatically and, when they finish, the session is closed.
Output
Section titled “Output”Returns a ZoanMicrosoftFilesSession. It exposes DriveId (the resolved drive), SiteId (or null) and Account (the name of the OneDrive’s owner, the given mailbox or me). With body you do not need the output (the session is inherited) and Connect returns nothing. Without body, assign it to a variable and pass it as session to the other activities.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
Credential 'm365-operations' could not be resolved. Verify it exists in Zoan Automation and that there is an active session. | There is no credential or connection with that key name in the environment, or the robot has no Zoan Cloud session. Check the key name (not the display name) and that the connection is Connected. |
'credential' does not contain a valid access_token. Check the Microsoft 365 OAuth Connection in Zoan Cloud. | The credential resolved to an empty value. Reconnect the connection in Zoan Cloud. |
InvalidAuthenticationToken (Microsoft Graph, 401) | The credential value is not a token: this usually happens when writing "m365-operations" instead of credential("m365-operations"). |
Could not resolve the user's drive. Provide 'driveId'. | Microsoft Graph returned no drive for the account or mailbox. Give driveId. |
itemNotFound / ResourceNotFound (Microsoft Graph, 404) | The mailbox does not exist or has no OneDrive provisioned. |
accessDenied (Microsoft Graph, 403) | The connection is not allowed to read that user’s drive (missing Files.ReadWrite.All). |
To retry on transient Microsoft 365 failures, wrap the block in Retry; to handle the error and continue, in Try / Catch.
Example
Section titled “Example”OneDrive/SharePoint — Connect credential = credential("m365-operations") └─ body: OneDrive/SharePoint — Upload path = "C:\reports\today.pdf" destination = "Reports/today.pdf" → output: uploaded OneDrive/SharePoint — Share id = uploaded["id"] email = "customer@mail.com" role = viewFiles and lists of the same SharePoint site:
OneDrive/SharePoint — Connect credential = credential("m365-operations") siteId = siteId driveId = libraryId └─ body: OneDrive/SharePoint — List files → output: documents SharePoint — Get list items list = "Requests" → output: requestsRelated activities
Section titled “Related activities”- OneDrive/SharePoint — Upload — upload a file.
- OneDrive/SharePoint — List files — list or search files.
- SharePoint — Get list items — read a SharePoint list.
- All OneDrive / SharePoint activities