Docs / Workflows / Integrations / OneDrive
OneDrive
Read, organise and upload files in OneDrive or a SharePoint document library, and edit Excel workbooks.
What you can do
Each OneDrive integration’s page in OAIZ shows these uses, with its events and its read and write actions, under What you can do with OneDrive.
- Order table
- Add a row to an Excel table for every new order.
- File summaries
- Summarise each file added to a shared folder.
- File sorting
- Move uploaded files into folders by customer or type.
Connection scope
The connection reaches the user’s own OneDrive through a work, school or personal Microsoft account. With a work or school account it also reaches a SharePoint document library that a call names by driveId. Omit driveId to use the user’s own OneDrive. itemId identifies a file or folder within its drive. Listing and search results return both IDs.
SharePoint libraries and the Excel tools need a work or school account. The file tools also work with a personal account. The Excel tools read and edit regular .xlsx files.
Connecting
Choose OneDrive in OAIZ and authorize the Microsoft account the workflows should use. If this service is being added to an existing Microsoft connection, use the same account.
This service requests Files.Read.All, Files.ReadWrite.All, Sites.Read.All and Sites.ReadWrite.All to access files and sites available to the connected account. Every Microsoft connection also requests openid, profile, email, offline_access and User.Read for account identity and renewal. Enabling another Microsoft service adds that service’s permissions to the shared connection.
File reads check for Files.Read.All. File writes and every Excel tool, including the Excel reads, check for Files.ReadWrite.All. List Document Libraries checks for Sites.Read.All.
Read actions
- List Files
- List the files and folders directly inside the drive root or one folder, one page of up to 100 items at a time. Each item carries its itemId and driveId.
- Search Files
- Search file names, metadata and content in the user’s own OneDrive or one library, one page of up to 100 results at a time in Microsoft’s relevance order.
- Get File
- Read one file’s or folder’s details by itemId: name, size, type, parent folder, drive, web link and version tags.
- Download File
- Download one file by itemId as an attached file of up to 25 MiB. Set format to pdf for a PDF copy of a DOCX, PPTX or XLSX file of at most 2,000,000 bytes. Folders and packages are refused.
- List Document Libraries
- List the document libraries of one SharePoint site with each library’s driveId. The site is given by its address, such as https://contoso.sharepoint.com/sites/Marketing. The tool does not search the organisation for sites.
- List Worksheets
- List the worksheets in a workbook, returning the worksheetId that Get Range and Update Range use.
- List Tables
- List the tables in a workbook, returning the tableId that Get Table Rows and Append Table Rows use.
- Get Range
- Read cell values from one A1 cell or rectangle of up to 100 rows and 50 columns.
- Get Table Rows
- Read table rows and their cell values, one page of up to 100 rows at a time. The table must have 1 to 50 columns.
Write actions
- Create Folder
- Create a folder in the drive root or inside folderId. The call fails when the destination already holds an item with that name.
- Rename File
- Rename a file or folder by itemId. The new name includes any file extension and fails when the folder already holds that name.
- Move File
- Move a file or folder to folderId in the same drive, or to the root when folderId is omitted. A name collision at the destination fails.
- Copy File
- Start a copy of a file or folder, with its contents, into folderId or the root of the same drive, with an optional new name. Microsoft accepting the copy does not confirm that it finished. List Files shows the finished copy.
- Delete File
- Delete a file or folder by itemId. Microsoft moves it, and any folder contents, to the recycle bin.
- Upload File
- Upload one OAIZ file of up to 25 MB into the root or folderId. A name already used in that folder fails. With attachEventFiles, the tool uploads the one file carried by the triggering event.
- Replace File Content
- Replace an existing file’s complete content with one OAIZ file of up to 25 MB, such as a generated Word or PowerPoint document. The file keeps its itemId and link. Version history follows the account or library settings.
- Update Range
- Write cell values into one A1 rectangle of up to 100 rows and 50 columns, then return the resulting values. Text is stored as literal text, never as a formula. null keeps a cell and an empty string clears it.
- Append Table Rows
- Add up to 100 rows to the end of a table. Each row matches the table’s column count. The result shows the values Microsoft stored.
Events
OneDrive events report changes in the user’s own OneDrive and in the SharePoint document libraries the connection watches. Libraries are added under Watched SharePoint libraries in the connection’s settings. A personal Microsoft account cannot watch libraries. Each event’s source names the drive that changed, and event types take the form e:microsoft-onedrive/file-changed.
- File Changed
- A file was added, edited, renamed or moved. The event carries the file’s state after the change, not which property changed, and several quick changes can arrive as one event. Folders do not fire it.
- File Deleted
- A file was deleted. Microsoft reports few details for a deleted item. A work or school account omits its name, and a deleted folder can also fire this event.
- File Created
- A new file appeared with a creation time after OAIZ started watching the drive.
- Folder Created
- A new folder appeared with a creation time after OAIZ started watching the drive.
- File Added To Folder
- A file was created in a folder or moved into one. addedBy is created or moved, and previousFolderId holds the earlier folder after a move.
- File Moved
- A file or folder OAIZ saw before now has a different parent folder. previousFolderId holds the earlier parent.
- File Renamed
- A file or folder OAIZ saw before now has a different name. previousName holds the earlier name and file.name the current one.
- File Restored
- A file or folder OAIZ saw deleted is live again. The event does not say how it was restored.
Only changes after the service was connected fire. OAIZ reads changes when Microsoft notifies it and runs a catch-up about every five minutes. A large burst of changes, such as uploading a folder of thousands of files, is read in parts and its events can arrive several minutes later. If Microsoft can no longer continue from OAIZ’s saved position, OAIZ restarts from the drive’s current state and the changes in between do not fire.
File Created, Folder Created, File Added To Folder, File Moved, File Renamed and File Restored compare each item with the state OAIZ last saw. Items that existed before watching started do not always report their first move or rename. Microsoft can merge intermediate changes, and no event separates a recycle-bin deletion from a permanent one.
Write behaviour
A write in a SharePoint library needs the library’s driveId, and its source and destination stay in that drive. An outcome_unknown result means OAIZ does not confirm whether Microsoft applied the write. Read the item, range or table before repeating it.
In a library, Upload File and Replace File Content can also set document column values through libraryColumns. Columns are keyed by internal name, not display name. Content, columns and check-in are separate steps, and libraryWrite lists the steps Microsoft confirmed when a call stops part way.