# Integrating with SharePoint

[Prerequisites](#prerequisites)

[Azure Setup](#drivetrain-setup)\
&#x20;   [Step 1: Register an Application in Azure](#step-1-connect-your-onedrive-account)

[Drivetrain Setup](#drivetrain-setup)\
&#x20;  [Step 1: Connect your SharePoint Account](#step-1-connect-your-onedrive-account-1)\
&#x20;  [Step 2: Import File to Drivetrain](#step-2-import-file-to-drivetrain)

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* Admin privileges in Azure Portal
* Admin privileges in Drivetrain
* The table you want to import should start from the first cell (A1) on the sheet
* None of the column headers should be empty
* There should only be one table per file
* Only .XLSX and .CSV files are supported

## Azure Setup <a href="#drivetrain-setup" id="drivetrain-setup"></a>

### **Step 1: Register an Application in Azure** <a href="#step-1-connect-your-onedrive-account" id="step-1-connect-your-onedrive-account"></a>

1. Login to [Azure Portal](https://portal.azure.com/#home) and search for "**App Registrations**" on the Azure home page.&#x20;

<figure><img src="/files/ydVWbKzZtthVVcfMVUEu" alt=""><figcaption></figcaption></figure>

2. Click on **+ New registration**

<figure><img src="/files/xFzRE0rn9Kez1M63E6bS" alt=""><figcaption></figcaption></figure>

3. Enter the name as "**Drivetrain SharePoint Integration**" and select **Accounts in this organizational directory only** as the supported account types and click **Register**

<figure><img src="/files/GfIMfNNC0bVNikN0ZrrR" alt=""><figcaption></figcaption></figure>

4. On the next page, note down the **Application (client) ID** and **Directory (tenant) ID** in a secure document, these will be needed to configure SharePoint in Drivetrain.

<figure><img src="/files/JVk0tJ8A25nI36KVPE0m" alt=""><figcaption></figcaption></figure>

5. On the left navigation menu, under manage click on "**Certificates & secrets**" and click on **+ New client secret**
6. Enter the description as "**Drivetrain SharePoint App**" and select maximum expiry date and click on **Add**
7. Note Value and Secret ID of the SharePoint application.

<figure><img src="/files/vcQUVvFrQzFkHV17TLPW" alt=""><figcaption></figcaption></figure>

8. Navigate to **API Permissions** and click on **+ Add a Permission** and select **Microsoft Graph**
9. Under **Application Permissions,** search files and select **files.read** and **files.ReadWrite.all** permissions

<figure><img src="/files/3LtIFz6JFl11UXSuX7SA" alt=""><figcaption></figcaption></figure>

10. After selecting the Files permissions, search for **Sites** and select **Sites.FullControl.All, Sites.Read.All, Sites.ReadWrite.All** and click on Add permissions

<figure><img src="/files/Tq40JaITZcO2uInD2TzA" alt=""><figcaption></figcaption></figure>

11. Once you save the permissions, click on Grant admin consent to apply the permissions.&#x20;

<figure><img src="/files/asvZjXZVoppVq6zOzMNs" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/eTZ6zIfvpyIa0xg7zdMQ" alt=""><figcaption></figcaption></figure>

12. Go to your SharePoint account, and go to the home page of your site which stores files to be pulled into Drivetrain and get the URL of that site. For eg: your sample URL will be yourcompany.sharepoint.com/sites/YourSiteName

<figure><img src="/files/yyoEv5RrveomGZGlNboD" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Please note that you have all the four details, as these will be needed to configure Sharepoint connector in Drivetrain:

1. Client ID
2. Client Secret  (Value of SharePoint Application, generated in step 7 of SharePoint Setup)
3. Tenant ID
4. Site URL
   {% endhint %}

## Drivetrain Setup <a href="#drivetrain-setup" id="drivetrain-setup"></a>

### **Step 1: Connect your SharePoint Account** <a href="#step-1-connect-your-onedrive-account" id="step-1-connect-your-onedrive-account"></a>

1. Click on **+** button on top left corner

<figure><img src="/files/mh4KhbOcFOV4Lwt6b7f5" alt=""><figcaption></figcaption></figure>

2. Select the SharePoint connector under Spreadsheets category
3. Enter the details received in SharePoint Setup i.e. Client ID, Client Secret, Tenant ID and Site URL

<figure><img src="/files/w5yANijgkqe7tClOHxdJ" alt=""><figcaption></figcaption></figure>

4. Once your SharePoint connector is authenticated, you will be redirected back to Drivetrain **Connected Integrations** page.
5. To add files, click on ‘**Add Data**’ and enter the URL of the file you want to import.

### **Step 2: Import File to Drivetrain** <a href="#step-2-import-file-to-drivetrain" id="step-2-import-file-to-drivetrain"></a>

1. Open SharePoint and navigate to the file you want to import
2. Copy the URL of the file which needs to be imported

{% hint style="info" %}
Please copy the URL using the address bar (see below image) and not using the copy link option available in OneDrive
{% endhint %}

<figure><img src="/files/k0kCV4JHdHvUm9UtmjqP" alt=""><figcaption></figcaption></figure>

3. Paste your SharePoint File Link into the field provided and click **Add**

<figure><img src="/files/iFrZr41t692aKrmZi6ly" alt=""><figcaption></figcaption></figure>

3. Please wait for some few mins until the sync is completed, the file you added will now show up in the list of tables on SharePoint connector

## FAQ <a href="#faq" id="faq"></a>

<details>

<summary>Can I load/refresh data from a SharePoint File?</summary>

Yes, you can connect your Sharepoint Account to Drivetrain. It'll be synced (i.e, refreshed) with the changes at predefined intervals. Alternatively, you can also [trigger a manual sync](https://docs.drivetrain.ai/getting-started/data/explore-your-datasets#resync). Refer to the above guide for more details

</details>


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
