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/ If you want to download files from sharepoint Site you can bypass steps 6,7,8 and 9, make a GET with this type of URL first : ‘/sites/{IDSite}/drives‘ to retrieve the driveID
Parse the JSON response and make a filter on your desired site (webURL) to retrieve only 1 driveID
11/ To List the content, make a GET with this kind of URL : ‘/drives/{driveID}/root:/Fic:/Children‘
(*) ‘Fic’ is my Subfolder name (can be replaced with your ID)
12/ use the Datamapper to make a loop to download each file by calling a flow
13/ In the Called Flow, do 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 and set the {urladdition} parameter to : ‘/drives/{DriveID}/items/root:/{SubfolderName}/{Filename}:/content‘
Below steps are mandatory
(*) Set DataBlob parameter with a Blob variable. Use the File2Blb function to load the file content and Update the Blob variable with BINARY encoding
(**) Don’t forget to Set the “Request Content Type” with the desired content in the REST Client configuration screen
(for PDF : application/pdf, for JPEG : image/jpeg and so on so forth …)
(***) Set the Desired Encoding to Binary in the configuration screen
15/ To delete a file, do a Delete HTTP operation with this type of URL : ‘https://graph.microsoft.com/v1.0/sites/{IDSite}/lists/{IDList}/items/{FileID}‘ in the configuration screen
16/ If you want to retrieve data Content from Sharepoint List, Do a Get with this type of URL : ‘https://graph.microsoft.com/v1.0/sites/{IDSite}/lists/{IDList}/items?$expand=fields($select=*)
You can specify select * to retrieve all columns.
(*) https://learn.microsoft.com/en-us/graph/api/listitem-list?view=graph-rest-1.0&tabs=http
The ID of the site that you want can be retrieve with a Get on https://graph.microsoft.com/v1.0/sites
The ID of the list that you want can be retrieve with a Get on https://graph.microsoft.com/v1.0/sites/{IDSite}/lists/
You can use a Datamapper to parse the JSON response and map you desired columns to a Flat File
17 / Documentation
https://learn.microsoft.com/en-us/graph/api/overview?view=graph-rest-1.0&preserve-view=true