CSOM Microsoft.SharePoint.Client.Web throws exception when loading ServerRelativePath.
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)
- [x] 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
- Create a SharePoint context with any URL.
- Try to retrieve the Web.ServerRelativePath property.
- 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.
Hello @raghus-axiomint, Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.
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.
@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.
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
@raghus-axiomint, right @fheinicke server version update, broken the "serverRelativePath" property $serverRelativePath = Get-PnPProperty -ClientObject $web -Property "ServerRelativePath"
Get-PnPProperty: Field or property "ServerRelativePath" does not exist.
@Ashlesha-MSFT We're aware that the update from server version 16.0.25722.12007 to 16.0.25729.1200 broke the property. That's in this issue's description too. What we want to know now is, what is Microsoft doing to fix this issue?
@raghus-axiomint, We were able to reproduce the issue, and we are investigating it. We have logged this as a bug, and our engineering team will look into it.
@Ashlesha-MSFT What's the typical SLA (Service Level Agreement) to resolve a bug like this that has impacted thousands of users worldwide?
I had a support ticket open for this case for a while and was notified today that the product team deployed a fix for the issue. In my tests on multiple tenants, the bug is fixed in both server versions that I now see (16.0.25812.12010 and 16.0.25812.12011).
@raghus-axiomint , @fheinicke
I too have observed that ServerRalativePath property is working now.
We are closing this issue for now. If the problem persists, feel free to reopen it or open a new one.