> For the complete documentation index, see [llms.txt](https://integrations.drivetrain.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://integrations.drivetrain.ai/integration-guide/readme/spreadsheets/integrating-with-sharepoint.md).

# Integrating with SharePoint

Connect SharePoint to Drivetrain with an Azure app and import .xlsx or .csv files. Covers app registration, Sites.Read.All, adding files, and troubleshooting.

You register an app in Microsoft Entra ID (Azure) that can read your SharePoint sites, enter its details in Drivetrain, then add each file you want as a dataset by pasting its URL. Each URL adds one sheet of an .xlsx workbook, or one .csv file.

## Before you start

* You're a Drivetrain **Admin**.
* You can **register an app** in Microsoft Entra ID, and a Microsoft 365 admin can **grant tenant-wide admin consent** to it.
* Your site URL looks like `https://<tenant>.sharepoint.com/sites/<site>`. Sites under `/teams/` can't be connected.
* Files are **.xlsx** or **.csv**, stored in that site's default document library. A connection reads files from **its own site only**.

Drivetrain signs in as the app (no user), so it needs the **application** permission **Sites.Read.All**. It's read-only: it lets the app read documents and list items in all site collections. Drivetrain only reads the files you add.

## Step 1: Register an app in Azure

1. Sign in to the [Azure portal](https://portal.azure.com/#home) and search for **App registrations**.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-53faa0521f6ef09cc0a6b300ed7990eb2c8afc6b%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

2. Click **+ New registration**.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-d740a22071441d0221fa9db5bbf3d3afb4673353%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

3. Name it (for example **Drivetrain SharePoint Integration**), select **Accounts in this organizational directory only**, and click **Register**.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-dd651200c6566d6aec5a3ef8ceecbf315623b568%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

4. Copy the **Application (client) ID** and **Directory (tenant) ID**.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-d9b78bafd50a408ac565b5a18feedf4e4d5d6dae%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

5. Go to **Certificates & secrets** → **Client secrets** → **+ New client secret**, add a description, pick an expiry and click **Add**.
6. Copy the secret's **Value** (not the Secret ID). Azure shows it only once.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-3c0369e5b27ef5c6e09a908c9add09c736a07775%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Secrets expire (24 months at most). Note the date: when the secret expires, syncs fail until you [enter a new one](#update-credentials-or-disconnect).
{% endhint %}

7. Go to **API permissions** → **+ Add a permission** → **Microsoft Graph** → **Application permissions**, select **Sites.Read.All**, and click **Add permissions**.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-18a003e53dd714b58e7142c78e061d1972eec816%2FSharePoint%20-%20Request%20API%20permissions%20-%20Files.Read.All.png?alt=media" alt=""><figcaption></figcaption></figure>

8. Click **Grant admin consent** and confirm. The permission's status shows as granted.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-33e3588dcf6113044b74fe113445fa2ac6a928df%2FSharePoint%20-%20Grant%20admin%20consent%20confirmation.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-241b3af5d7e372124dd86d61caf37e27d3bf4886%2FSharePoint%20-%20Admin%20consent%20granted.png?alt=media" alt=""><figcaption></figcaption></figure>

9. In SharePoint, open the home page of the site that holds your files and copy its URL, for example `https://yourcompany.sharepoint.com/sites/Finance`.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-62bc33bc838fc58f3f2bfa233e13f433bf2ecb0f%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## Step 2: Connect SharePoint in Drivetrain

1. On the **Data** page, click the **+** icon next to **Data** and select **SharePoint**.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-8645a523a904f5f97f2aea4538435c3dbbd081d2%2Fod-1.webp?alt=media" alt=""><figcaption></figcaption></figure>

2. Fill in:
   * **Application (Client) ID**
   * **Secret Key (Value)**: the secret's Value from step 6
   * **Directory (Tenant) ID**
   * **Site URL**: exactly `https://<tenant>.sharepoint.com/sites/<site>`, with nothing after the site name
3. Click **Submit**.

Drivetrain checks only the Site URL format at this point. A wrong ID or secret shows up when you add your first file.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-c363e4de55b59ad6aae0fe059728349583ed8159%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## Step 3: Add a file

1. In SharePoint, open the file in your browser.
2. Copy the URL from the address bar. It must contain `sourcedoc=` and `file=`.

{% hint style="warning" %}
Don't use SharePoint's **Copy link** or **Share** link. It doesn't contain `sourcedoc=` and Drivetrain rejects it.
{% endhint %}

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-d47f1236f5285c8bd81c09233c1104f4c946d800%2Fod-8.webp?alt=media" alt=""><figcaption></figcaption></figure>

3. On the SharePoint connection, click **Add data** and paste the URL. Drivetrain checks that it can open the file (a green tick appears).
4. For an .xlsx file, pick the tab in **Sheet name**.
5. Click **Add**.

<figure><img src="https://4220329029-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmBZR0D9lq6jrI895OuOU%2Fuploads%2Fgit-blob-8962768295a74955b1c2a81c44815d79b5a1a0d2%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

The file appears as a dataset under the SharePoint connection once its first sync finishes. Repeat for each file or tab.

## Format your file

* The table starts at **cell A1**, and **row 1** holds the column headers. No header may be empty.
* Each tab holds **only one table**.
* Formulas import as the values last saved in the file. Cells with formula errors (such as `#N/A` or `#REF!`) import as blank.
* Drivetrain stops reading a sheet after 1,000 blank rows in a row, so keep the data contiguous.

## Syncing

Each sync re-reads every file you added in full. Files sync automatically with your other data sources. To refresh now, open the connection's **⋮** menu and click **Sync**.

Don't rename or delete a tab you've added: the next sync can't find it and fails. To use a different tab, add it as a new dataset.

## Update credentials or disconnect

* **New client secret:** create it in Azure (step 5), then open the connection's **⋮** menu, click **Edit credentials**, enter all four fields again (with the new secret's Value in **Secret Key (Value)**) and click **Update credentials**.
* **Disconnect:** open the connection's **⋮** menu and click **Remove**. To revoke access entirely, delete the app registration in Azure.

## Troubleshooting

<details>

<summary>Invalid SharePoint site URL format. Expected format: https://&#x3C;tenant_name>.sharepoint.com/sites/&#x3C;site_name></summary>

Enter the site's home URL only: `https://`, your `.sharepoint.com` domain, `/sites/` and the site name, with no page or folder after it. Site names can contain only letters, numbers, `_` and `-`.

</details>

<details>

<summary>We couldn't open the SharePoint site '…'</summary>

Check the site link, and that the app has **Sites.Read.All** (Application) with admin consent granted.

</details>

<details>

<summary>Microsoft couldn't return the SharePoint site '…' right now</summary>

A temporary Microsoft error. Try again in a few minutes. If it keeps failing, contact support and quote the Microsoft reference in the message.

</details>

<details>

<summary>An unexpected error occurred. Please try again.</summary>

Usually wrong credentials: the **Application (Client) ID**, **Directory (Tenant) ID** or secret is wrong (often the Secret ID was entered instead of the Value), or the secret has expired. Re-enter all four fields with [Edit credentials](#update-credentials-or-disconnect).

</details>

<details>

<summary>The source file must be from the same SharePoint site as configured in the connection settings</summary>

The file is on a different site from the connection's **Site URL**. Move the file to that site's default document library. This can show up after **Add**, as the connection's failure reason ("Failed to add table").

</details>

<details>

<summary>Invalid link. It must contain a sourcedoc</summary>

You pasted a sharing link. Open the file in your browser and copy the URL from the address bar.

</details>

<details>

<summary>The file '…' was not found in SharePoint/OneDrive or is not accessible</summary>

The file was moved or deleted, the link is wrong, or the app lost access. Check the file opens from the URL, then click **Retry fetching**.

</details>

<details>

<summary>The first row of this file is empty</summary>

Drivetrain checks the workbook's **first** sheet, whichever tab you picked. Make sure that sheet's table starts at A1 with headers in row 1, or move a cover sheet behind your data sheets, then add the file again.

</details>

<details>

<summary>We couldn't read the sheets in '…' because the workbook is too large for Microsoft to open</summary>

Remove unused sheets or replace formulas with their values to shrink the file, or save the data as a .csv and add that instead.

</details>

<details>

<summary>Syncs started failing after working for months</summary>

The client secret has probably expired. Create a new one and [update it in Drivetrain](#update-credentials-or-disconnect).

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://integrations.drivetrain.ai/integration-guide/readme/spreadsheets/integrating-with-sharepoint.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
