Claude Code Can't Open SharePoint Links? Use the WebDAV Path

スポンサーリンク
Claude Code Can't Open SharePoint Links? Use the WebDAV Path Claude
スポンサーリンク

On my work PC (Windows) I asked Claude Code to read files in SharePoint. I pasted the folder link from my browser (the one starting with https://), and it stopped, saying SharePoint can’t be opened with WebFetch, nor with MCP.

Short answer: rewrite the https link into the WebDAV form “\\yourcompany.sharepoint.com@SSL\DavWWWRoot\…”, open it once in File Explorer yourself so Windows gets your sign-in (credentials), then give Claude Code the same path. It can read the files. After I added a conversion rule to CLAUDE.md, I can just paste the https link and Claude Code switches to the WebDAV form by itself.

What happened

First I pasted the SharePoint link from the browser’s address bar into Claude Code. The answer: SharePoint can’t be opened with WebFetch (Claude Code’s feature for reading web pages) or MCP.

When I asked it to think of another way, Claude Code suggested a WebDAV path. Windows can open files on a web server like a network folder through WebDAV. SharePoint supports this, so Claude Code can read the files like any normal folder.

I opened the rewritten path in File Explorer first, then told Claude Code to read it in the WebDAV form, and it could read the files.

Steps to try first

1. Rewrite the https link into the WebDAV form

Say the link of your SharePoint folder looks like this (replace yourcompany, team, folder with your own):

https://yourcompany.sharepoint.com/sites/team/Shared%20Documents/folder

Rewrite it like this:

\\yourcompany.sharepoint.com@SSL\DavWWWRoot\sites\team\Shared Documents\folder

There are only four rules:

  • Replace the leading “https://” with “\\”
  • Append “@SSL\DavWWWRoot” after “yourcompany.sharepoint.com” (@SSL means connect over https)
  • Change the remaining “/” to “\”
  • Decode “%20” and similar escapes back to the original characters (“%20” is a space; non-ASCII folder names like “%E8%B3%87…” must be decoded too)

The last one is easy to forget. According to Microsoft’s documentation, since Windows 10 version 1803 a “%20” in a UNC path is no longer treated as a space but as the literal characters “%20”. Without decoding, Windows looks for a folder with a different name.

If rewriting by hand is tedious, paste these 7 lines into PowerShell. Put your SharePoint link inside the quotes on line 1; the last line prints the converted path.

$url = "https://yourcompany.sharepoint.com/sites/team/Shared%20Documents/folder"
$u = [Uri]$url
$p = $u.AbsolutePath
if ($u.Query -match '[?&]id=([^&]+)') { $p = $Matches[1] }
$p = [Uri]::UnescapeDataString($p) -replace '^/:[a-z]+:/r', ''
$p = $p.TrimEnd('/') -replace '/', '\'
"\\$($u.Host)@SSL\DavWWWRoot$p"

Line 4 handles links of the form “…/Forms/AllItems.aspx?id=…” (for example when opened from a document library list) by taking the folder location after “id=”. The part of line 5 that removes “/:f:/r” is for links like “…sharepoint.com/:f:/r/sites/…”. Anything like “?web=1” at the end is ignored.

I tested five kinds of links (with the fictional company contoso) in Windows PowerShell 5.1 on Windows 11, and all converted as expected:

Before: https://contoso.sharepoint.com/sites/team/Shared%20Documents/%E8%B3%87%E6%96%99/2026
After:  \\contoso.sharepoint.com@SSL\DavWWWRoot\sites\team\Shared Documents\資料\2026

Before: https://contoso.sharepoint.com/sites/team/Shared Documents/資料/report.xlsx?web=1
After:  \\contoso.sharepoint.com@SSL\DavWWWRoot\sites\team\Shared Documents\資料\report.xlsx

Before: https://contoso.sharepoint.com/sites/team/Shared%20Documents/Forms/AllItems.aspx?id=%2Fsites%2Fteam%2FShared%20Documents%2F%E8%B3%87%E6%96%99&viewid=abc
After:  \\contoso.sharepoint.com@SSL\DavWWWRoot\sites\team\Shared Documents\資料

Before: https://contoso.sharepoint.com/:f:/r/sites/team/Shared%20Documents/%E8%B3%87%E6%96%99?csf=1&web=1&e=xyz
After:  \\contoso.sharepoint.com@SSL\DavWWWRoot\sites\team\Shared Documents\資料

Before: https://contoso.sharepoint.com/sites/team/Shared%20Documents/
After:  \\contoso.sharepoint.com@SSL\DavWWWRoot\sites\team\Shared Documents

(資料 in the test is a Japanese folder name, used to check decoding.) Sharing links like “…/:f:/s/…” followed by random characters don’t contain the folder location, so they can’t be converted. Open such a link in the browser and use the address bar link of the folder that opens.

2. Open it in File Explorer yourself to get the credentials

Paste the rewritten path into File Explorer’s address bar and press Enter. If the SharePoint folder’s contents appear, you’re set.

This step is what gets your SharePoint sign-in (credentials) in the first place. The Windows component that connects to SharePoint over WebDAV (the WebClient service) can’t show a sign-in page itself. Once you have signed in through File Explorer, the same sign-in is used when Claude Code reads that path (see “Why” below).

The sign-in expires. If Claude Code suddenly can’t read the files, open the path in File Explorer again.

If even File Explorer can’t open it, check the Windows “WebClient” service, which handles WebDAV. This PowerShell line shows its Status and StartType (read-only, changes nothing):

Get-Service WebClient | Format-List Name,DisplayName,Status,StartType

Microsoft’s documentation says that if StartType is “Disabled”, using SharePoint as a network drive won’t work correctly, and it must be “Manual” or “Automatic”. On my home PC (Windows 11) Status was “Stopped” with StartType “Manual”. The WebClient service isn’t started by default (Microsoft’s list of deprecated features says so too), so Stopped is normal. If it’s Disabled on a work PC, it’s safer to ask your IT team than to change it yourself.

3. Give Claude Code the WebDAV path

Once File Explorer opens it, give the same path to Claude Code, for example:

Read the files in the following folder, then summarize them.
Don't use WebFetch; read it as a network folder.
\\yourcompany.sharepoint.com@SSL\DavWWWRoot\sites\team\Shared Documents\folder

In my environment, this let Claude Code read the files in the folder.

Put a conversion rule in CLAUDE.md

Rewriting every time is tedious, so I wrote a rule in CLAUDE.md. Since then I can paste the https link and Claude Code converts it to the WebDAV form by itself.

CLAUDE.md is the instruction file Claude Code reads at the start of every session. According to the official docs, its location decides its scope:

  • ~/.claude/CLAUDE.md (in the .claude folder of your user folder): applies to all your projects
  • CLAUDE.md in the project folder (or .claude/CLAUDE.md): applies only to that project; shared with your team if committed to Git

If SharePoint comes up in all your work, ~/.claude/CLAUDE.md is easiest. Example content (replace yourcompany with your company’s SharePoint name):

## Reading SharePoint links
- When given a link starting with "https://yourcompany.sharepoint.com/", don't use WebFetch or MCP. Convert it to a WebDAV path and read it as a network folder.
- How to convert: replace "https://yourcompany.sharepoint.com" with "\\yourcompany.sharepoint.com@SSL\DavWWWRoot" and change the remaining "/" to "\". Decode URL escapes such as "%20" back to the original characters.
- Example: https://yourcompany.sharepoint.com/sites/team/Shared%20Documents/docs is read as \\yourcompany.sharepoint.com@SSL\DavWWWRoot\sites\team\Shared Documents\docs
- For links like ".../Forms/AllItems.aspx?id=...", use the part after id= (URL-decoded) as the folder location.
- If it can't be read, ask me to open that path once in File Explorer.
- Only read files on SharePoint. Never create, modify or delete them.

I recommend keeping the last line. SharePoint opened through WebDAV allows writing and deleting files, just like in File Explorer. Saying it explicitly keeps Claude Code from changing or deleting shared company files as a side effect. As the official docs note, CLAUDE.md is guidance Claude tries to follow, not a setting that blocks operations. When important folders are involved, decline when Claude Code asks permission to write or delete.

Why the https link can’t be opened

https links bounce you if you aren’t signed in

SharePoint Online returns nothing to requests without a sign-in. When I requested a document library URL on SharePoint Online (Microsoft’s own microsoft.sharepoint.com) without credentials, a browser-like request was redirected to the sign-in page (/_layouts/15/Authenticate.aspx), while other requests got “401” (authentication required) with this message (checked November 14, 2026):

Access denied. Before opening files in this location, you must first browse to the web site and select the option to login automatically.

WebFetch is Claude Code’s own feature for fetching web pages. According to the official docs it sends only a User-Agent (starting with Claude-User) plus an Accept header. It doesn’t send the cookies from your signed-in browser, so company SharePoint bounces it as above. That’s what “can’t be opened with WebFetch” means.

WebDAV connects using the sign-in cookies you obtained

With a WebDAV path, the Windows WebClient service handles the SharePoint traffic, and to File Explorer or other apps it looks like a normal folder. About authentication, Microsoft’s documentation says:

  • The WebClient service can’t display a sign-in page, so it uses the authentication cookies created when you sign in. They must be persistent cookies saved with an expiry
  • The SharePoint Online authentication cookies are “rtFa” and “FedAuth”. Microsoft Edge’s “View in File Explorer” feature is also configured to use these two for WebDAV authentication
  • The WebClient service looks for usable cookies in the WinInet (Windows internet functions) cache
  • When using SharePoint Online as a network drive, cookies eventually expire, so you need to visit the site occasionally and choose “Stay signed in” again

So the flow is: you open the WebDAV path in File Explorer and sign in, which stores the authentication cookies in Windows. Claude Code runs as the same user on the same PC, so when it reads files at that path, the WebClient service connects using those cookies. Claude Code can’t show a sign-in page or type a password, so that first sign-in has to be done by you.

Cautions

  • Check your company’s rules: letting Claude Code read SharePoint means giving company information to an AI. Stay within your company’s AI usage policy
  • The WebClient (WebDAV) service is deprecated: Microsoft announced it as a deprecated feature in November 2023. It still works, but development has stopped and it may be removed from future Windows versions
  • Watch out for writes and deletes: as above, the WebDAV path allows changing files. If you only want reading, say “read only” in CLAUDE.md and in your requests

Summary

  • Given a SharePoint https link, Claude Code said it couldn’t open it with WebFetch or MCP
  • Rewriting it to “\\yourcompany.sharepoint.com@SSL\DavWWWRoot\…”, opening it in File Explorer to get the cookies, then giving it to Claude Code worked
  • Rules: https:// → \\, add @SSL\DavWWWRoot, / → \, decode %20 etc.
  • With a rule in CLAUDE.md, pasting the https link is enough; also write “read only, never create, modify, delete”

References

Tested with Claude Code on a Windows work PC against our company SharePoint Online. The conversion script was tested in Windows PowerShell 5.1 on my home PC.

コメント

Copied title and URL