Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSOM Microsoft.SharePoint.Client.Web throws exception when loading ServerRelativePath. #10122

Open
1 of 9 tasks
raghus-axiomint opened this issue Feb 18, 2025 · 4 comments
Open
1 of 9 tasks
Labels
type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Comments

@raghus-axiomint
Copy link

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

SharePoint CSOM

Developer environment

Windows

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

No response

Describe the bug / error

We recently have been experiencing an issue when loading the ServerRelativePath property of the Web object. We understand that web server update from version 16.0.25722.12007 to 16.0.25729.12006 broke this (ServerRelativePath) property. Microsoft's workaround to use Web.RootFolder.ServerRelativePath property is not foolproof because the access fails if the user does not have sufficient permissions. Unfortunately, Web.ServerRelativeUrl is not a solution either since it doesn't support paths containing % and # characters (refer to https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/supporting-and-in-file-and-folder-with-the-resourcepath-api).

Steps to reproduce

  1. Create a SharePoint context with any URL.
  2. Try to retrieve the Web.ServerRelativePath property.
  3. Notice the exception that comes up when you try to retrieve the property.

Expected behavior

There shouldn't be any exceptions, and the property should be retrieved.

@raghus-axiomint raghus-axiomint added the type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. label Feb 18, 2025
@ChetanSharma-msft
Copy link

Hello @raghus-axiomint,
Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.

@Ashlesha-MSFT
Copy link

Hello @raghus-axiomint,
Could you share the exact exception that occurs when you attempt to retrieve the Web.ServerRelativePath property?
It would be helpful to see the exact sample code you're using to retrieve this property.

@raghus-axiomint
Copy link
Author

@Ashlesha-MSFT Please find below the exception and stack trace.

Exception:
Microsoft.SharePoint.Client.ServerException: 'Field or property "ServerRelativePath" does not exist.'

Stack Trace:
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at TestProject.SharePoint.SharePointExtensions.<>c__DisplayClass1_0.b__0(ClientRequestWrapper wrapper) in D:\Projects\TestProject\SharePoint\SharePointExtensions.cs:line 101
at Axiom.Net.SharePoint.SharePointExtensions.ExecuteWithRetry(Action`1 executeAction, String url, String tag, String callerName) in D:\Projects\TestProject\SharePoint\SharePointExtensions.cs:line 146
Sample Code:
// GetClientContext method is an internal method that returns the "ClientContext" object.
using (var context = GetClientContext(url, siteCollection))
{
context.Load(context.Web,
site => site.ServerRelativePath,
site => site.Title);
// Server exception is being thrown when completing the request
context.ExecuteQueryWithRetry();
}

@fheinicke
Copy link

The bug can also be easily triggered using PnP PowerShell:

Connect-PnPOnline [...]

# Check server version
(Get-PnPContext).ServerVersion

# Get web and property
$web = Get-PnPWeb
$serverRelativePath = Get-PnPProperty -ClientObject $web -Property "ServerRelativePath"

I was able to pinpoint it to the change of the server version from 16.0.25722.12007 (working fine) to 16.0.25729.12006 (broken) that was rolling out ~10 days ago.

This MS Learn Q&A discussion is on the same issue:
https://learn.microsoft.com/en-us/answers/questions/2156350/csom-microsoft-sharepoint-client-web-throws-except

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
Projects
None yet
Development

No branches or pull requests

4 participants