Skip to content

Fix InitPath procedure to extract and prepend SharePoint site path to…#6241

Merged
JesperSchulz merged 1 commit intomicrosoft:mainfrom
StefanSosic:fix-sharepoint-initpath
Jan 22, 2026
Merged

Fix InitPath procedure to extract and prepend SharePoint site path to…#6241
JesperSchulz merged 1 commit intomicrosoft:mainfrom
StefanSosic:fix-sharepoint-initpath

Conversation

@StefanSosic
Copy link
Copy Markdown
Contributor

@StefanSosic StefanSosic commented Jan 21, 2026

… file paths

Summary

The Problem:
The SharePoint connector was failing with a 400 Bad Request error when trying to download files because the paths being sent to SharePoint's REST API were incomplete.

Root Cause:
SharePoint REST API requires server-relative URLs that include the full site path.

For example:
Wrong: /Shared Documents/TEST/Design.png
Correct: /sites/mysite/Shared Documents/TEST/Design.png

The original implementation only combined the base folder path with the file path, but didn't extract and prepend the site path from the SharePoint URL.

Work Item(s)

Fixes #3872

Fixes AB#619102

@StefanSosic StefanSosic requested a review from a team as a code owner January 21, 2026 13:23
@github-actions github-actions bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork labels Jan 21, 2026
@JesperSchulz JesperSchulz added Integration GitHub request for Integration area Linked Issue is linked to a Azure Boards work item labels Jan 21, 2026
@JesperSchulz JesperSchulz self-assigned this Jan 21, 2026
@github-actions github-actions bot added this to the Version 28.0 milestone Jan 21, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a critical bug in the SharePoint connector where file downloads were failing with 400 Bad Request errors because paths sent to SharePoint's REST API were incomplete. The issue occurred because the connector was not extracting and prepending the SharePoint site path (e.g., "/sites/mysite") from the SharePoint URL to file paths, resulting in incorrect server-relative URLs.

Changes:

  • Modified the InitPath procedure to extract the site path from the SharePoint URL and prepend it to file paths
  • Added a new GetSitePathFromUrl helper method to extract the site path using the Uri codeunit
  • Updated path construction logic to ensure proper server-relative URLs are sent to SharePoint's REST API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JesperSchulz JesperSchulz merged commit 49228f4 into microsoft:main Jan 22, 2026
54 of 55 checks passed
@JesperSchulz
Copy link
Copy Markdown
Contributor

Backported for release with 27.4.

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 From Fork Pull request is coming from a fork Integration GitHub request for Integration area Linked Issue is linked to a Azure Boards work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Can't Open or Download File from External File Storage (SharePoint Online)

4 participants