# Navigation and file operations on SharePoint

Microsoft SharePoint • Microsoft Graph • Mindflow

## Overview

This guide explains how to navigate SharePoint files and folders through Mindflow using Microsoft Graph steps (Sites + Files). It extends this page with the key identifiers you will see in Graph responses and how to chain them to list folders/files and download content.

## Key concepts (Site ID, Drive ID, Drive Item ID)

When working with SharePoint content via Microsoft Graph, you will typically manipulate three identifiers:

- **Site ID**
  - Identifies a SharePoint site (example: a team site such as `https://…sharepoint.com/sites/Demo`).
  - You usually obtain it first (from a prior step or an input variable), then use it to list drives.
- **Drive ID**
  - Identifies a document library inside a site (Graph calls it a “drive”).
  - You obtain it by listing drives for a given site.
- **Drive item ID**
  - Identifies an item inside a drive.
  - A drive item can be:
    - a **folder** (that you can list children for)
    - a **file** (that you can download / read metadata for)
  - Special case: **`root`** is a valid drive item reference representing the top-level of the drive.

### About `@microsoft.graph.downloadUrl`

Many Graph “drive item” responses include a `@microsoft.graph.downloadUrl`:

- It is a **pre-authenticated direct download link** generated by Microsoft.
- It typically **expires**, so you should avoid storing it long-term.
- Best practice: **generate / use it close to the moment you need to download**.
- In folder traversal flows, you will see fresh `@microsoft.graph.downloadUrl` values returned again when you list children and inspect individual items.

:::note
**Do not treat `@microsoft.graph.downloadUrl` as a stable identifier.** Use IDs (site/drive/driveItem) for navigation, and use `@microsoft.graph.downloadUrl` as an ephemeral download convenience.
:::

---

## Navigating sites and folders (typical chain)

Below is the most common navigation pattern:

1. **List drives from a site** (Sites)
2. Pick the correct **drive ID** (document library)
3. **List children of a drive item** (Files) starting from `root` or from a folder drive item ID
4. For each returned item:
   - If it is a folder: keep its **drive item ID** to list deeper
   - If it is a file: use its metadata (including `@microsoft.graph.downloadUrl`) for file operations

---

## Step 1 — List drives from a site

**Mindflow step:** Microsoft Graph - Sites → “Get drives from sites (sites_ListDrives…)”

### Inputs

- `Site id` (required)
  - The SharePoint site identifier you want to browse.

### Output (what to look for)

The response returns a list of drives (document libraries). Typical fields:

- `value[n].id` → **Drive ID** (this is what you will pass to the Files steps)
- `value[n].name` → Human-readable library name (example: `Documents`)
- `value[n].webUrl` → The SharePoint URL for that library
- `value[n].driveType` → Often `documentLibrary`

### Example screenshots (sensitive data obfuscated)

- **Screenshot 1 — List drives step (input):** shows the “Get drives from sites …” step with the `Site id` field populated.

  <div class="docs-screenshot-compact">

  ![Value n drivetype often documentlibrary](./assets/value-n-drivetype-often-documentlibrary.png)

  </div>

- **Screenshot 2 — List drives step (output):** highlights the returned `value[0].id` (Drive ID), `name`, and `webUrl`.

   <div class="docs-screenshot-compact">

   ![Value n drivetype often documentlibrary](./assets/value-n-drivetype-often-documentlibrary-2.png)

   </div>

---

## Step 2 — List children from the drive root

**Mindflow step:** Microsoft Graph - Files → “List children of a driveItem”

### Inputs

- `Drive id` (required)
  - Use the drive `id` returned by the previous step.
- `Drive item id` (required)
  - Use `root` to start from the top level of the document library.

### Output (what to look for)

The response returns the items directly under that folder:

- `value[n].id` → **Drive item ID**
- `value[n].name` → File or folder name
- `value[n].folder` → Present when the item is a folder
- `value[n].file` → Present when the item is a file
- `value[n].webUrl` → Browser link in SharePoint
- `value[n].@microsoft.graph.downloadUrl` → Pre-authenticated download URL (ephemeral)

### Example screenshots (sensitive data obfuscated)

Add the screenshot(s) below:

- **Screenshot — Root children listing (input):** shows `Drive id = …` and `Drive item id = root`.

  <div class="docs-screenshot-compact">

  ![Value n microsoft graph downloadurl pre](./assets/value-n-microsoft-graph-downloadurl-pre.png)

  </div>

- **Screenshot — Root children listing (output):** highlights the returned `value` array and at least one item’s `id`, `name`, and (when present) `@microsoft.graph.downloadUrl`.

  <div class="docs-screenshot-compact">

  ![Value n microsoft graph downloadurl pre](./assets/value-n-microsoft-graph-downloadurl-pre-2.png)

  </div>

- **Screenshot — Additional children listing example (output with download URL)**: highlights the `@microsoft.graph.downloadUrl` field returned for a file item (example download link).

   <div class="docs-screenshot-compact">

   ![Value n microsoft graph downloadurl pre](./assets/value-n-microsoft-graph-downloadurl-pre-3.png)

   </div>

---

## Step 3 — Traverse into a folder (repeatable)

**Mindflow step:** Microsoft Graph - Files → “List children of a driveItem”

### Inputs

- `Drive id` (required)
  - Same drive ID as before.
- `Drive item id` (required)
  - Set to the **folder’s** `value[n].id` returned by the previous listing.

### Output

Same shape as the root listing, but scoped to that folder.

### Example screenshots (sensitive data obfuscated)

Add the screenshot(s) below:

- **Screenshot — Folder children listing (input):** shows `Drive item id` set from the selected folder’s `id` (variable/token).

  <div class="docs-screenshot-compact">

  ![Set folders value n id returned](./assets/set-folders-value-n-id-returned.png)

  </div>

- **Screenshot — Folder children listing (output):** highlights the folder name (e.g., `GRC Demo`) and the items returned inside it.

   <div class="docs-screenshot-compact">

   ![Set folders value n id returned](./assets/set-folders-value-n-id-returned-2.png)

   </div>

---

## Downloading, uploading, and sharing files

This section shows common file operations you can implement once you can navigate to the correct **drive item**.

---

### Download a file (using `@microsoft.graph.downloadUrl`)

A common pattern is:

1. Identify the target file drive item (from a folder listing)
2. Read its `@microsoft.graph.downloadUrl`
3. Perform an HTTP `GET` on that URL to retrieve the binary content

#### Inputs

- `@microsoft.graph.downloadUrl`
  - Use the `@microsoft.graph.downloadUrl` returned by Microsoft Graph for the target file.

#### Output (what to look for)

- The HTTP response body contains the file bytes (content-type depends on the file: XLSX/PDF/etc.).

:::note
`@microsoft.graph.downloadUrl` is time-limited. Generate it close to the download operation and avoid storing it.
:::

#### Example screenshots (sensitive data obfuscated)

Add the screenshot(s) below:

- **Screenshot — HTTP Request (input)**: shows an HTTP step configured with `Method = GET` and `URL = MICROSOFT.GRAPH.DOWNLOADURL`.

  <div class="docs-screenshot-compact">

  ![Http response body contains file bytes](./assets/http-response-body-contains-file-bytes.png)

  </div>

- **Screenshot — HTTP Request (output)** (`Screenshot 2026-03-25 at 15.48.18.png`): shows a successful response (`code = 200`, `status = OK`) and the returned binary content-type.

   <div class="docs-screenshot-compact">

   ![Http response body contains file bytes](./assets/http-response-body-contains-file-bytes-2.png)

   </div>

---

### Copy a file

When you need to produce an output file in SharePoint (for example, a result workbook based on a template), the simplest approach is often to **copy** an existing reference/template file into a destination folder, optionally renaming it.

This avoids dealing with raw upload/update semantics and keeps your flow based on drive item IDs.

#### Example: “Copy” a file into a folder

**Mindflow step:** Microsoft Graph - Files → “Copy”

#### Inputs

- `Drive id`
  - The drive (document library) that contains the source item.
- `Drive item id`
  - The **source** file drive item ID to copy.
- `Name`
  - The destination filename.
- `Item reference.id`
  - The **destination folder** drive item ID (where the copy should be created).

#### Output (what to look for)

- A response indicating the copy job has been accepted.
- In most cases, you then list the destination folder to retrieve the new file’s drive item ID.

#### Example screenshots (sensitive data obfuscated)

Add the screenshot(s) below:

- **Screenshot — Copy step (input)**: shows `Drive id`, `Drive item id` (source), `Name`, and `Item reference.id` (destination folder).

   <div class="docs-screenshot-compact">

   ![Most cases you then list destination](./assets/most-cases-you-then-list-destination.png)

   </div>

---

### Retrieve the copied/new file (list children + filter)

After a copy/upload, you often need to retrieve the newly created file’s drive item ID.

**Mindflow step:** Microsoft Graph → Files → “List children of a driveItem”

#### Inputs

- `Drive id`
  - The drive where the destination folder lives.
- `Drive item id`
  - The destination folder drive item ID (example: `RESULTFOLDERID`).
- `Filter` (optional — enable via the **Advanced** button shown in the screenshot)
  - You can filter the results by file name using Microsoft Graph filter syntax.
  - Use the operator `eq` and wrap the expected name in **single quotes**.
  - The value must be the **full file name**, including its extension.
  - Example: `name eq 'FILENAME'`

#### Output (what to look for)

- The returned item entry for the file (capture its `id`, `name`, and optionally `@microsoft.graph.downloadUrl`).

#### Example screenshots (sensitive data obfuscated)

Add the screenshot(s) below:

- **Screenshot — List children (input)**: shows the destination `Drive item id` and a `Filter` by name.

   <div class="docs-screenshot-compact">

   ![Returned item entry file capture its](./assets/returned-item-entry-file-capture-its.png)

   </div>
