SharePoint Online – Magic xpi: How to Get the Content list of a SharePoint folder ,download files locally and upload Files using REST Microsoft Graph API

Describe the different steps for connecting Magic xpi with SharepointOnline using REST Microsoft Graph API

1/ Define in Azure Portal An app registration and add permission for Sharepoint through Microsoft Graph

2/ Check that you can have access via Postman

3/ Define a REST Client Resource in Magic xpi Studio

4/ Define 2 Paths /{list} and /{urladdition}

5/ To Get the Sharepoint ID Site that you want, Drag and Drop REST Client connector and configure the connector like below and click OK

(*) In my example sharepoint web site is : https://magicsw365.sharepoint.com/sites/MSEFRANCE

6/ Parse the JSON response with the mapper to retrieve the ID

6/ To List the content of the website, use a GET with this type of URL ‘/sites/{IDSite}/lists

7/ Parse the JSON response to retrieve the ID List that you want (set the condition that you want (for example : Src.JSON”S1/Root Schema/value/A Schema/webUrl” =’https://magicsw365.sharepoint.com/sites/MSEFRANCE/FRANCE’)

8/ To list the items, make a GET with this kind of URL : ‘/sites/{IDSite}/lists/{IDList}/items

9/ If you want to retrieve only the SubFolders list, parse the JSON Response like below

10/ To download files from sharepoint Site, make a GET with this kind of URL first : ‘/sites/{IDSite}/drives‘ to retrieve the driveID

Parse the JSON response

11/ To List the content, make a GET with this kind of URL : ‘/drives/{driveID}/root:/Fic:/Children

(*) ‘Fic’ is my Subfolder name

12/ use the Datamapper to make a loop to download each file by calling a flow

13/ In the SubFlow, make a simple HTTP GET with the downloadUrl

And use FileManagement component to save the file locally

14/ To Upload a file on “Fic” subfolder, make a Put with this kind of URL : ‘/drives/{DriveID}/items/root:/{SubfolderName}/{Filename}:/content

(*) Give a Blob variable that holds the file content to DataBlob

15/ To delete a file, make a Delete with this kind of URL : ‘/sites/{IDSite}/lists/{IDList}/items/{FileID}

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Retour en haut