Skip to content

[28.x] Add Microsoft Graph API Support to SharePoint Connector#9561

Open
JesperSchulz wants to merge 2 commits into
releases/28.xfrom
jesperschulz-backport-5833-sharepoint-graph-api
Open

[28.x] Add Microsoft Graph API Support to SharePoint Connector#9561
JesperSchulz wants to merge 2 commits into
releases/28.xfrom
jesperschulz-backport-5833-sharepoint-graph-api

Conversation

@JesperSchulz

@JesperSchulz JesperSchulz commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Backport

Backports #5833 to the releases/28.x branch.

Cherry-picked the squash merge commit 30b880e0 onto releases/28.x. One conflict in ExtSharePointConnectorImpl.Codeunit.al was resolved by taking the PR's dispatch-based implementation — the only divergence on 28.x was a cosmetic TempSharePointFileSharePointFile variable rename in method bodies that the PR deletes entirely.

Original summary

Adds Microsoft Graph API support as an alternative to the existing SharePoint REST API, with a backward-compatible Use legacy REST API toggle. Graph API supports downloading files larger than 150 MB via chunked transfers, which the SharePoint REST API cannot.

  • New field Use legacy REST API on Ext. SharePoint Account table/page to select the API stack
  • Refactored Ext. SharePoint Connector Impl to dispatch operations to REST vs Graph based on the flag
  • New codeunits: Ext. SharePoint Graph Helper, Ext. SharePoint REST Helper, Ext. SharePoint Upgrade (existing accounts default to legacy REST on upgrade so nobody silently switches stacks)
  • Extended the app idRanges to 4610
  • Added unit tests for the account table, graph helper, REST helper, dispatch routing, and upgrade

Backport verification

  • System Application SharePoint Graph module (dependency SharePoint Graph API support #3655) is already present on 28.x; all SharePoint Graph Client methods called by the helper exist with matching signatures.
  • The certificate SetParameters fix referenced by the original PR is already present on 28.x's GraphAuthClientCredentials (it was not part of the squash diff).

Fixes #5383
Fixes AB#612932

<!-- Thank you for submitting a Pull Request. If you're new to
contributing to BCApps please read our pull request guideline below
* https://github.com/microsoft/BCApps/Contributing.md
-->

Implements [Idea

Business Central limits the maximum HTTP response content size to 150 MB
by default (controlled by the `NavHttpClientMaxResponseContentSize`
server setting). This limitation causes file downloads from SharePoint
to fail for files larger than this threshold.

While chunked downloads would solve this issue, SharePoint REST APIs do
not support chunked downloads (only uploads). Microsoft Graph API,
however, does support this capability.

This PR introduces Microsoft Graph API support as an alternative
implementation alongside the existing SharePoint REST API, with a
backward-compatible toggle to switch between the two.

- **New field**: Added "Use Graph API" toggle in
`ExtSharePointAccount.Table.al` and `ExtSharePointAccount.Page.al` to
control API selection
- **Improved UX**: Updated tooltips to clarify folder path requirements
for both APIs
- **Refactored implementation**: Modified
`ExtSharePointConnectorImpl.Codeunit.al` to route operations based on
API selection
- **New codeunits**:
- `ExtSharePointGraphHelper.Codeunit.al`: Encapsulates Graph API
operations for files and directories
- `ExtSharePointRestHelper.Codeunit.al`: Encapsulates existing REST API
operations
- **Bug fix**: Fixed certificate parameter assignment in
`GraphAuthClientCredentials.Codeunit.al` that prevented
certificate-based authentication from working correctly

Depends on SharePoint module additions in the System Application (see

- **Removes file size limitations**: Graph API supports downloading
files larger than 150 MB through chunked downloads
- **Flexibility**: Users can choose the API that best fits their
requirements
- **Clean permissions model**: App registration can use either
SharePoint REST or Graph API permissions without mixing
- **Backward compatible**: Existing implementations continue to work
without changes

- Account table — secret storage round-trips, auth methods are mutually
exclusive (setting one clears the other's keys), new accounts default to
Graph.
- Upgrade — existing accounts get Use legacy REST API = true, so nobody
silently switches API stacks on upgrade.
- Graph helper — HTTP-level tests via [HttpClientHandler]: listing
filters files vs folders, base-path composition (incl. trailing-slash
edge), downloaded content survives the stream hand-over, ≤4 MB uses
simple upload vs >4 MB creates an upload session + chunks, copy uses
native /copy, move uses PATCH, exists-check returns false on 404 but
errors on 500, correct verbs for delete/create, disabled account fails
before any HTTP.
- REST helper — same operation set for the legacy stack, asserting the
actual requests sent (download/upload/delete legs). Notably: copy must
not delete the source, move must — the delete leg is the only difference
between them.
- Dispatch — calls go through Ext. SharePoint Connector Impl and assert
the Use legacy REST API flag routes to exactly one API family
(graph.microsoft.com vs /_api/). Sampled on 3 of the 11 operations since
the dispatch code is uniform.

needs to be open and approved. Submitting PRs with no linked issues or
unapproved issues is highly discouraged. -->
Fixes #5383

Fixes
[AB#612932](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/612932)

---------

Co-authored-by: Tine Staric <tine.staric@companial.com>
Co-authored-by: Bert Verbeek <bverbeek@4ps.nl>
Co-authored-by: Jesper Schulz-Wedde <JesperSchulz@users.noreply.github.com>
Co-authored-by: Jesper Schulz-Wedde <jeschulz@microsoft.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 30b880e)
@JesperSchulz
JesperSchulz requested review from a team July 17, 2026 07:27
@JesperSchulz
JesperSchulz requested a review from a team as a code owner July 17, 2026 07:27
@github-actions github-actions Bot added Build: Automation Workflows and other setup in .github folder AL: System Application Build: scripts & configs Build scripts and configuration files AL: Tools AL: Business Foundation AL: Apps (W1) Add-on apps for W1 labels Jul 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Issue #5383 is not valid. Please make sure you link an issue that exists, is open and is approved.

@JesperSchulz
JesperSchulz changed the base branch from main to releases/28.x July 17, 2026 07:37
@JesperSchulz JesperSchulz reopened this Jul 17, 2026
@github-actions github-actions Bot removed Build: Automation Workflows and other setup in .github folder AL: System Application Build: scripts & configs Build scripts and configuration files AL: Tools AL: Business Foundation labels Jul 17, 2026
@JesperSchulz JesperSchulz added the Integration GitHub request for Integration area label Jul 17, 2026
The 28.x CodeCop ruleset flags variables of TableType=Temporary tables
that are prefixed with Temp (AA0237), whereas main requires the prefix.
Rename TempSharePointFile/TempSharePointFolder/TempGraphDriveItem to
match the 28.x convention so the SharePoint Connector app compiles.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fb130121-74a3-45cb-9907-c89e38e78f16
@JesperSchulz JesperSchulz removed the Integration GitHub request for Integration area label Jul 17, 2026
@github-actions github-actions Bot added the Integration GitHub request for Integration area label Jul 17, 2026
pull Bot pushed a commit to Mattlk13/BCApps that referenced this pull request Jul 17, 2026
## Symptom
The team-ownership classification workflow
(`.github/workflows/ownership-classification.yml`) in microsoft/BCApps
rejects correct classifications as malformed, failing with:

> The ownership result from BCAppsTriage was malformed, so no labels
were changed.

This broke a real PR: microsoft/BCApps microsoft#9561 (base `releases/28.x`,
linked issue microsoft#5383) was correctly classified as team `Integration` with
`source: pull_request:linked-issue`, but the workflow threw the
malformed error and applied no labels.

## Root cause
The `Validate and apply ownership result` step validates
`result.ownership.source` against a hardcoded `sources` allowlist. A
merged BCAppsTriage change (PR #40, linked-issue PR routing) added a new
emitted source value `pull_request:linked-issue` — a PR whose team is
adopted from its linked issue when the changed files are ambiguous. The
BCApps allowlist was never updated, so any such result is rejected as
malformed.

## Fix
Add `'pull_request:linked-issue'` to the `sources` allowlist,
immediately after `'pull_request:incomplete-files'`. This restores
parity with the classifier's `decision.js` source set in BCAppsTriage —
the only emitted source value missing from the allowlist. The allowlist
now contains all 12 valid source values.

Single-line change; no other edits.

Fixes
[AB#642506](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/642506)

---------

Co-authored-by: Jesper Schulz-Wedde <jesper.schulzwedde@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 Integration GitHub request for Integration area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BC Idea]: Add Graph API support to Ext. File Storage Sharepoint Connector

2 participants