Skip to main content

Read / Write SharePoint Files

graph explorer knowledge needed

Create App Registration

App Registration will be used to authenticate against Microsoft Graph API.

Permissions

With API Permission "Sites.Selected" you can specify on which SharePoint-Sites the App Registration will have permissions to read/write files and properties.

image.png

Get Site ID

To get the site id of your sharepoint sites to to the following link in a Webbrowser:

GET https://<tenantname>.sharepoint.com/sites/<sitename>/_api/site/id
Example: https://lucanoahcaprez.sharepoint.com/sites/SPS-LNC-WebFiles-PROD/_api/site/id

Example XML Response in Browser:

image.png

Get Folder ID

Folder IDs can be found using the graph explorer and the Site ID:

GET https://graph.microsoft.com/v1.0/sites/<SiteID>/drives

Example JSON Response in Graph Explorer:

image.png

Get Folder Documents

Get folder documents and content with graph api:

GET https://graph.microsoft.com/v1.0/sites/<SiteID>/drives/<FolderID>
Example: https://graph.microsoft.com/v1.0/sites/22c1c748-f7e0-4f10-97f4-64b51694a0ca/drives/b!SMfBIuD3EE-X9GS1FpSgypE4hAdzBPVAhzjowjy6CTAFMPrY5yGSRYYXW7Jhy97f

Example JSON Response in Graph Explorer:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives/$entity",
    "createdDateTime": "2021-04-03T23:11:15Z",
    "description": "",
    "id": "b!SMfBIuD3EE-X9GS1FpSgypE4hAdzBPVAhzjowjy6CTAFMPrY5yGSRYYXW7Jhy97f",
    "lastModifiedDateTime": "2022-05-06T07:25:15Z",
    "name": "Dokumente",
    "webUrl": "https://bkwfmbenergie.sharepoint.com/sites/T_BKW_Test_CAPRL/Freigegebene%20Dokumente",
    "driveType": "documentLibrary",
    "createdBy": {
        "user": {
            "displayName": "Systemkonto"
        }
    },
    "lastModifiedBy": {
        "user": {
            "displayName": "Systemkonto"
        }
    },
    "owner": {
        "group": {
            "email": "T_BKW_Test_CAPRL@bkwfmbenergie.onmicrosoft.com",
            "id": "bab76dba-25aa-4804-8cad-4fde62da958b",
            "displayName": "Besitzer von T_BKW_Test_CAPRL"
        }
    },
    "quota": {
        "deleted": 0,
        "remaining": 27487376431088,
        "state": "normal",
        "total": 27487790694400,
        "used": 414263312
    }
}