# Read SharePoint file information via Graph API

<p class="callout info">Requirements: Graph Explorer knowledge needed.</p>

### Create App Registration

An App Registration will be used to authenticate against Microsoft Graph API. For creating an App Registration there is an other detailed guide.

### 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](https://docs.lucanoahcaprez.ch/uploads/images/gallery/2022-11/scaled-1680-/PWLimage.png)](https://docs.lucanoahcaprez.ch/uploads/images/gallery/2022-11/PWLimage.png)

### Get Site ID

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

GET https://&lt;tenantname&gt;.sharepoint.com/sites/&lt;sitename&gt;/\_api/site/id  
Example: [https://lucanoahcaprez.sharepoint.com/sites/SPS-LNC-WebFiles-PROD/\_api/site/id](https://lucanoahcaprez.sharepoint.com/sites/SPS-LNC-WebFiles-PROD/_api/site/id)

Example XML Response in Browser:

[![image.png](https://docs.lucanoahcaprez.ch/uploads/images/gallery/2022-11/scaled-1680-/Mhzimage.png)](https://docs.lucanoahcaprez.ch/uploads/images/gallery/2022-11/Mhzimage.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/&lt;SiteID&gt;/drives  
Example: https://graph.microsoft.com/v1.0/sites/22c1c748-f7e0-4f10-97f4-64b51694a0ca/drives

<details id="bkmrk-example-json-respons"><summary>Example JSON Response from Graph API</summary>

<div><div>{</div><div> "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",</div><div> "value": [</div><div> {</div><div> "createdDateTime": "2021-04-03T23:11:15Z",</div><div> "description": "",</div><div> "id": "b!SMfBIuD3EE-X9GS1FpSgypE4hAdzBPVAhzjowjy6CTAFMPrY5yGSRYYXW7Jhy97f",</div><div> "lastModifiedDateTime": "2022-05-06T07:25:15Z",</div><div> "name": "Dokumente",</div><div> "webUrl": "https://&lt;tenantname&gt;.sharepoint.com/sites/&lt;sitename&gt;/Freigegebene%20Dokumente",</div><div> "driveType": "documentLibrary",</div><div> "createdBy": {</div><div> "user": {</div><div> "displayName": "Systemkonto"</div><div> }</div><div> },</div><div> "lastModifiedBy": {</div><div> "user": {</div><div> "displayName": "Systemkonto"</div><div> }</div><div> },</div><div> "owner": {</div><div> "group": {</div><div> "email": "&lt;sitename&gt;@&lt;tenantname&gt;.onmicrosoft.com",</div><div> "id": "bab76dba-25aa-4804-8cad-4fde62da958b",</div><div> "displayName": "Besitzer von &lt;sitename&gt;"</div><div> }</div><div> },</div><div> "quota": {</div><div> "deleted": 0,</div><div> "remaining": 27487376431088,</div><div> "state": "normal",</div><div> "total": 27487790694400,</div><div> "used": 414263312</div><div> }</div><div> },</div><div> {</div><div> "createdDateTime": "2021-04-06T13:42:16Z",</div><div> "description": "",</div><div> "id": "b!SMfBIuD3EE-X9GS1FpSgypE4hAdzBPVAhzjowjy6CTA3sb9Pi_NxRJ3lfYXRyKTz",</div><div> "lastModifiedDateTime": "2021-10-02T21:16:08Z",</div><div> "name": "Vertragsablage",</div><div> "webUrl": "https://&lt;tenantname&gt;.sharepoint.com/sites/&lt;sitename&gt;/&lt;foldername&gt;",</div><div> "driveType": "documentLibrary",</div><div> "createdBy": {</div><div> "user": {</div><div> "displayName": "Systemkonto"</div><div> }</div><div> },</div><div> "lastModifiedBy": {</div><div> "user": {</div><div> "displayName": "Systemkonto"</div><div> }</div><div> },</div><div> "owner": {</div><div> "group": {</div><div> "email": "&lt;sitename&gt;@&lt;tenantname&gt;.onmicrosoft.com",</div><div> "id": "bab76dba-25aa-4804-8cad-4fde62da958b",</div><div> "displayName": "Besitzer von &lt;sitename&gt;"</div><div> }</div><div> },</div><div> "quota": {</div><div> "deleted": 0,</div><div> "remaining": 27487376431088,</div><div> "state": "normal",</div><div> "total": 27487790694400,</div><div> "used": 414263312</div><div> }</div><div> },</div><div> {</div><div> "createdDateTime": "2022-09-15T09:41:10Z",</div><div> "description": "sharepoint list",</div><div> "id": "b!SMfBIuD3EE-X9GS1FpSgypE4hAdzBPVAhzjowjy6CTC6kAXUUK7qSLG7oSTLYNsQ",</div><div> "lastModifiedDateTime": "2022-09-15T09:41:10Z",</div><div> "name": "Teams Wiki Data",</div><div> "webUrl": "https://&lt;tenantname&gt;.sharepoint.com/sites/&lt;sitename&gt;/Teams%20Wiki%20Data",</div><div> "driveType": "documentLibrary",</div><div> "createdBy": {</div><div> "user": {</div><div> "email": "&lt;creatorupn&gt;",</div><div> "id": "9e5da9b4-7023-4d36-86f5-33768907270f",</div><div> "displayName": "&lt;creatordisplayname&gt;"</div><div> }</div><div> },</div><div> "lastModifiedBy": {</div><div> "user": {</div><div> "email": "&lt;creatorupn&gt;",</div><div> "id": "9e5da9b4-7023-4d36-86f5-33768907270f",</div><div> "displayName": "&lt;creatordisplayname&gt;"</div><div> }</div><div> },</div><div> "owner": {</div><div> "group": {</div><div> "email": "&lt;sitename&gt;@&lt;tenantname&gt;.onmicrosoft.com",</div><div> "id": "bab76dba-25aa-4804-8cad-4fde62da958b",</div><div> "displayName": "Besitzer von &lt;sitename&gt;"</div><div> }</div><div> },</div><div> "quota": {</div><div> "deleted": 0,</div><div> "remaining": 27487376431088,</div><div> "state": "normal",</div><div> "total": 27487790694400,</div><div> "used": 414263312</div><div> }</div><div> }</div><div> ]</div><div>}</div></div></details>### Get Folder Documents

Get folder documents and content with graph api:

GET https://graph.microsoft.com/v1.0/sites/&lt;SiteID&gt;/drives/&lt;FolderID&gt;  
Example: [https://graph.microsoft.com/v1.0/sites/22c1c748-f7e0-4f10-97f4-64b51694a0ca/drives/b!SMfBIuD3EE-X9GS1FpSgypE4hAdzBPVAhzjowjy6CTAFMPrY5yGSRYYXW7Jhy97f](https://graph.microsoft.com/v1.0/sites/22c1c748-f7e0-4f10-97f4-64b51694a0ca/drives/b!SMfBIuD3EE-X9GS1FpSgypE4hAdzBPVAhzjowjy6CTAFMPrY5yGSRYYXW7Jhy97f)

Example JSON Response in Graph Explorer:

<details id="bkmrk-%7B-%C2%A0-%C2%A0-%22%40odata.contex"><summary>Example JSON Response from Graph API</summary>

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