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
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG1-1024x600.png)
2/ Check that you can have access via Postman
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG2-1024x584.png)
3/ Define a REST Client Resource in Magic xpi Studio
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG3-1024x342.png)
4/ Define 2 Paths /{list} and /{urladdition}
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG4-1024x523.png)
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
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG5-1024x592.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG6-1024x319.png)
6/ Parse the JSON response with the mapper to retrieve the ID
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG7-1024x315.png)
6/ To List the content of the website, use a GET with this type of URL ‘/sites/{IDSite}/lists‘
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG8-1024x482.png)
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’)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG9-1024x376.png)
8/ To list the items, make a GET with this kind of URL : ‘/sites/{IDSite}/lists/{IDList}/items‘
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG10-1024x353.png)
9/ If you want to retrieve only the SubFolders list, parse the JSON Response like below
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG11-1024x385.png)
10/ To download files from sharepoint Site, make a GET with this kind of URL first : ‘/sites/{IDSite}/drives‘ to retrieve the driveID
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG12-1024x300.png)
Parse the JSON response
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG13-1024x319.png)
11/ To List the content, make a GET with this kind of URL : ‘/drives/{driveID}/root:/Fic:/Children‘
(*) ‘Fic’ is my Subfolder name
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG14-1024x270.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG15.png)
12/ use the Datamapper to make a loop to download each file by calling a flow
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG16-1024x321.png)
13/ In the SubFlow, make a simple HTTP GET with the downloadUrl
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG17-1024x355.png)
And use FileManagement component to save the file locally
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG18-1024x427.png)
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
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG19-1024x412.png)
15/ To delete a file, make a Delete with this kind of URL : ‘/sites/{IDSite}/lists/{IDList}/items/{FileID}‘
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG21-1024x523.png)
![](https://france.magicsoftware.com/blog/wp-content/uploads/2024/06/SP_MG20-1-1024x345.png)