SAP Help Home SAP Intelligent RPA Help Portal SAP Intelligent RPA Community

Module - Cloud Files Management (Microsoft OneDrive and SharePoint)

Set of activities related to Microsoft OneDrive and SharePoint file system management.

Activities

Get Remote File Information

Get information about a remote file using its source URL


Technical Name Type Minimal Agent Version
getRemoteFileInformation asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
sourceUrl string mandatory URL provided by Microsoft to open the file. It is not the download URL.

Output Parameters:

Name Type Description
fileInformation irpa_365online.remoteFileInformation Useful information about the file

Sample Code:

const info = await irpa_365online.fileManagement.getRemoteFileInformation('https://sap.sharepoint.com/:x:/r/sites/321365/My%20Path/08_Product_Development/myFile.xlsx?d=w30ff232031bc40...dc7c1c2be50&csf=1&web=1&e=MmD8gw');

Note:

This activity is useful to get driveId and fileId from a source url. driveId and fileId are used by many activities in Microsoft 365 Online SDK.

Errors:

Error Class Package Description
NotFound irpa_core File is not found.
InvalidArgument irpa_core Invalid arguments. DownloadUrls are not supported as input.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call grapAPI.


Get Remote Folder Information

Get information about a remote folder using its source URL


Technical Name Type Minimal Agent Version
getRemoteFolderInformation asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
sourceUrl string mandatory URL provided by Microsoft to open the folder.

Output Parameters:

Name Type Description
folderInformation irpa_365online.remoteFolderInformation Useful information about the folder

Sample Code:

const info = await irpa_365online.fileManagement.getRemoteFolderInformation('https://compagny.sharepoint.com/:f:/r/sites/1234/Shared%20Documents/Customers');

Note:

This activity is useful to get driveId and folderId from a source url. driveId and folderId are used by many activities in Microsoft 365 Online SDK.

Note:

OneNote files are considered as folders in Microsoft file system.

Errors:

Error Class Package Description
NotFound irpa_core Folder is not found.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call grapAPI.


Get File List

Retrieve a list of files from a remote or a local folder.


Technical Name Type Minimal Agent Version
getFileList asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
driveId string optional The drive ID of the remote drive. If empty, the local drive is used instead.
path string optional The path of the folder from which you want to retrieve the list of files.
filter irpa_365online.fileFilter optional Criteria to filter on.

Output Parameters:

Name Type Description
fileList Array.<irpa_365online.fileDescription> The list of files you want to retrieve.

Sample Code:

// get root files from local drive const list = await irpa_365online.fileManagement.getFilesFromRemoteFolder('');

Sample Code:

// get root files from remote drive const list = await irpa_365online.fileManagement.getFilesFromRemoteFolder('myDriveId');

Sample Code:

// get children of test/myFolder folder from local drive const list = await irpa_365online.fileManagement.getFilesFromRemoteFolder(undefined, 'test/myFolder');

Errors:

Error Class Package Description
RequestError irpa_core Error getting files list.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call grapAPI.


Download File

Download a file from Microsoft OneDrive or SharePoint.


Technical Name Type Minimal Agent Version
downloadFile asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
driveId string optional If empty, the local drive is used by default. Otherwise, the drive ID of the remote drive is used.
pathOrFileId string mandatory The path or the ID of the remote file.
localFilePath string mandatory Full path and file name of the local file.

Sample Code:

await irpa_365online.fileManagement.downloadFile(undefined, 'download.xlsx', 'C:\\myFolder\\download.xlsx');

Errors:

Error Class Package Description
RequestError irpa_core Error while downloading the file.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.
InvalidArgument irpa_core Destination must be a file path.


Create File

Create a file


Technical Name Type Minimal Agent Version
createFile asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
driveId string optional If empty, the local drive is used by default. Otherwise, the drive ID of the remote drive is used.
destinationPath string optional The destination path
fileName string mandatory Name of the file to be created
fileType irpa_365online.enums.fileTypes optional empty FileType - Type of the file to be created

Sample Code:

await irpa_365online.fileManagement.createFile(undefined, 'myFolder', 'myWorkbook.xlsx', irpa_365online.enums.fileTypes.workbook);

Errors:

Error Class Package Description
RequestError irpa_core Error creating the file.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.
NotFound irpa_core The path was not found.
FileAlreadyExists irpa_365online The file already exists.


Copy/Move File

Copy or Move File


Technical Name Type Minimal Agent Version
copyOrMoveFile asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
sourceRemoteFile irpa_365online.remoteFile mandatory The remote file that you want to copy or move
destinationRemoteFolder irpa_365online.remoteFolder mandatory Where you want to copy or move the file to
deleteSourceFile boolean optional false If set to true, move the file. If set to false, copy the file.
ifExisting irpa_365online.enums.replaceBehaviour optional throwError Action to be completed if the destination already contains a file with the same name.

Output Parameters:

Name Type Description
fileName string The name of the destination file (may be different if a duplicate was created)

Sample Code:

await irpa_365online.fileManagement.copyOrMoveFile({driveId: undefined, pathOrFileId: "file.txt"}, {path: "folder", driveId: undefined}, true, true);

Errors:

Error Class Package Description
RequestError irpa_core Error copying the file.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.
NotFound irpa_core The file was not found.
FileAlreadyExists irpa_365online The file in the destination folder already exists and ifExisting is throwError.


Upload File

Upload a file (new or replacing an existing file)


Technical Name Type Minimal Agent Version
uploadFile asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
driveId string optional If empty, the local drive is used by default. Otherwise, the drive ID of the remote drive is used.
uploadPath string optional The remote upload folder path.
localFilePath string mandatory Full path and file name of the local file.

Sample Code:

await irpa_365online.fileManagement.uploadFile(undefined, 'myFolder', 'C:\\myFolder\\upload.xlsx');

Errors:

Error Class Package Description
RequestError irpa_core Error uploading the file.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call graphAPI.
NotFound irpa_core The requested file has not been found, please check that the file is existing on your machine.
FileAlreadyExists irpa_365online The file already exists.


Delete File

Delete a file from Microsoft OneDrive or SharePoint.


Technical Name Type Minimal Agent Version
deleteFile asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
driveId string optional If empty, the local drive is used by default. Otherwise, the drive ID of the remote drive is used.
pathOrFileId string mandatory The path or the ID of the file you want to delete.

Sample Code:

// delete a file located on a remote drive designated by its id and its file id await irpa_365online.fileManagement.deleteFile('myDriveId', 'myfileId');

Sample Code:

// file located on the local onedrive, accessed by the file id await irpa_365online.fileManagement.deleteFile(undefined, 'myfileId');

Sample Code:

// file located on the local onedrive, accessed by the file path await irpa_365online.fileManagement.deleteFile(undefined, 'test/myfile.txt');

Errors:

Error Class Package Description
RequestError irpa_core Error accessing the requested file.
NotFound irpa_core Ressource not found.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call grapAPI.


Delete Folder

Delete a folder


Technical Name Type Minimal Agent Version
deleteFolder asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
driveId string optional If empty, the local drive is used by default. Otherwise, the drive ID of the remote drive is used.
folderPath string mandatory The path of the folder from which you want to retrieve the list of files
forceDelete boolean optional false Delete the folder even if it is not empty

Sample Code:

// delete a folder located on a remote drive designated by its id await irpa_365online.fileManagement.deleteFolder('myDriveId', 'myFiles');

Sample Code:

// delete a folder and its content, located on a remote drive designated by its id await irpa_365online.fileManagement.deleteFolder('myDriveId', 'myFiles', true);

Sample Code:

// delete a folder located on the local onedrive await irpa_365online.fileManagement.deleteFolder(undefined, 'myFiles');

Errors:

Error Class Package Description
RequestError irpa_core Error accessing the requested file.
NotFound irpa_core Ressource not found.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call grapAPI.
NotEmptyFolder irpa_365online The folder is not empty and forceDelete is false.


Share Content

Share a file or a folder.


Technical Name Type Minimal Agent Version
shareContent asynchronous WIN-3.24, MAC-3.24, CLOUD-3.34

Input Parameters:

Name Type Attributes Default Description
driveId string optional If empty, the local drive is used by default. Otherwise, the drive ID of the remote drive is used.
driveItem string mandatory The path or the ID of the file or folder.
users Array. mandatory Array of user e-mails.
accessType irpa_365online.enums.accessTypes mandatory Type of access to be granted
mailNotificationMessage string optional The notification message that will be sent by e-mail (only for readOnly or readWrite). If empty, no e-mail is sent.

Sample Code:

// Give read/write access to user1@company.com on a remote file described by its path. The user will receive a mail with the given message. await irpa_365online.fileManagement.shareContent('someDriveId', 'myFiles/someFile.xlsx', ['user1@company.com'], enums.accessTypes.readWrite, 'This file has been shared with you');

Sample Code:

// Give read only access to user1@company.com on a remote folder described by its path. The user will not receive a mail. await irpa_365online.fileManagement.shareContent('someDriveId', 'myFiles/subFolder', ['user1@company.com'], enums.accessTypes.readOnly);

Sample Code:

// Remove access to user1@company.com on a local file described by its path. The user will not receive a mail. await irpa_365online.fileManagement.shareContent(undefined, 'myFiles/someFile.xlsx', ['user1@company.com'], enums.accessTypes.noAccess);

Note:

For a given user, if the Share Content activity is applied on a folder, the accessType is given recursively, except if the user has already no access to the folder and a noAccess is required.

Note:

If a permission on a file or a folder has been previously given to a user through a share link, that permission will be overriden only if the share link is used only by that user.

Errors:

Error Class Package Description
RequestError irpa_core Error accessing the requested file.
NotFound irpa_core Ressource not found.
InvalidAuthenticationToken irpa_365online Invalid token was retrieved to call grapAPI.