Server relative URLs must start with SPWeb.ServerRelativeUrl” in reading web part properties! – Recently I was working on, to the get web part properties details from the SharePoint site page using the PowerShell CSOM, then I got this error “Exception calling “ExecuteQuery” with “0” argument(s): “Server relative URLs must start with SPWeb.ServerRelativeUrl” in reading web part properties!:“. In this, SharePoint troubleshooting I will share how to fix this error.

Before getting into the issue fixing let us understand what is Server Relative URL in SharePoint?
What is Server Relative URL in SharePoint?
In SharePoint, a Server Relative URL is a URL that is relative to the root of the SharePoint site or site collection. Unlike absolute URLs, which include the full path from the root of the web server, server relative URLs start from the root of the SharePoint site or site collection, omitting the domain and protocol.
Understanding Server Relative URLs
Components of a SharePoint URL
- Protocol:
https://
- Domain:
yourdomain.sharepoint.com
- Site Collection Path:
/sites/YourSiteCollection
- Specific Resource Path:
/Documents/yourfile.docx
Example Breakdown
- Absolute URL:
https://yourdomain.sharepoint.com/sites/YourSiteCollection/Documents/yourfile.docx
- Server Relative URL:
/sites/YourSiteCollection/Documents/yourfile.docx
Advantages of Using Server Relative URLs
- Portability: Server relative URLs are more portable because they do not include the domain and protocol, making it easier to move sites between environments (e.g., from a development to a production environment).
- Shorter and Cleaner: They are shorter and cleaner, which can simplify URL management and scripting.
- Consistency: When the SharePoint site is accessed via different domains or protocols, server relative URLs remain consistent.
Use Cases for Server Relative URLs
- Linking within SharePoint: When creating links within SharePoint pages, documents, or scripts, server relative URLs ensure that links are not broken if the site’s domain or protocol changes.
- API and Development: In SharePoint REST API calls and custom development, using server relative URLs can simplify code and make it more robust.
Examples of Server Relative URLs
- Site URL:
/sites/YourSiteCollection
- Library URL:
/sites/YourSiteCollection/Documents
- Item URL:
/sites/YourSiteCollection/Documents/yourfile.docx
How to Use Server Relative URLs in SharePoint
REST API Calls
When making REST API calls in SharePoint, you often need to use server relative URLs to specify the resource you’re interacting with.
Server relative URLs must start with SPWeb.ServerRelativeUrl”
How to fix the Exception calling “ExecuteQuery” with “0” argument(s): “Server relative URLs must start with SPWeb.ServerRelativeUrl” in reading web part properties!:?

Solution: Server relative URLs must start with SPWeb.ServerRelativeUrl”
The issue was in this line, the way I was passing the PageRelativeURL parameter.
$PageRelativeURL="/SitePages/TestWPPage.aspx"
#Parameters value $siteURL="globalsharepoint2020.sharepoint.com/sites/CustomSearchRND" $PageRelativeURL="/SitePages/TestWPPage.aspx" $downloadLocation=$directoryPathForFileDownloadLocation; $userName = "YourSPOUsername@tenant.domain.com" $passWord = "YourSPOPassword" #Parameters ends here. #Calling the GetWebPartPropertyDetail function and passing the parameters. GetWebPartPropertyDetails $siteURL $PageRelativeURL $userName $passWord
Change the $PageRelativeURL=”/SitePages/TestWPPage.aspx” to like below:
$PageRelativeURL="/sites/CustomSearchRND/SitePages/TestWPPage.aspx"
Note:
In the page relative URL, we need to pass the URL in the below format:
"/sites/yoursitename/SitePagesOrPages(library)/yourpage.aspx"
Server relative URLs must start with SPWeb.ServerRelativeUrl error in GetFolderByServerRelativeUrl REST API
We will get the server relative URLs must start with SPWeb.ServerRelativeUrl error while we call the GetFolderByServerRelativeUrl REST API either from Power Automate (Send HTTP request SharePoint), Postman Tool, Dot Net, PowerShell, or any other coding.
Using the below API URL just try to browse any document library for testing, and we will get the below-mentioned error:
globalsharepoint2020.sharepoint.com/sites/GSDRnD/_api/web/GetFolderByServerRelativeUrl('/Shared%20Documents')/Files

In the above example, we have passed the API URL like the below:
SiteURL/_api/web/GetFolderByServerRelativeUrl('/Shared%20Documents')/Files
And our site URL is as below:
globalsharepoint2020.sharepoint.com/sites/GSDRnD
So, inside the GetFolderByServerRelativeUrl we need to pass the path as below:
(‘/sites/GSDRnD/Shared%20Documents’)
Now, if we construct the API URL as below
globalsharepoint2020.sharepoint.com/sites/GSDRnD/_api/web/GetFolderByServerRelativeUrl('/sites/GSDRnD/Shared%20Documents')/Files
Then, we will get successful results.

Summary: ServerRelativeUrl error in SharePoint Online
Hence, in this troubleshooting, we have learned about how to fix the Exception calling “ExecuteQuery” with “0” argument(s): “Server relative URLs must start with SPWeb.ServerRelativeUrl” in reading web part properties!: error.
See Also: SharePoint Online PowerShell tutorial
You may also like the following SharePoint PowerShell tutorials:
- [Verified] Get all webparts from pages in a site using PowerShell in SharePoint Online
- Get document library inventory report in SharePoint using PowerShell script
- How to start SharePoint list workflow using PowerShell
- How to hide quick launch menu in SharePoint online using PnP PowerShell
- Edit user Permission is greyed Out SharePoint Online
- Get workflow inventory from SharePoint online using PowerShell CSOM
- Create a modern team site using PnP PowerShell in SharePoint
- In 2 steps convert a classic SharePoint page to modern using PnP
- SharePoint Online: Delete All Files from document library for the given date – PowerShell CSOM
- Create SharePoint online list using PnP provisioning template
- SharePoint Automation: PowerShell script to get remote server information
- Office 365: Retrieve hub sites and associated sites using PnP Powershell
- SharePoint Online Automation – O365 – Upload files to document library using PowerShell CSOM
- SharePoint Online Automation – O365 – Create multiple items in a list using PowerShell CSOM
- SharePoint Online Automation – O365 – Update document library metadata using PowerShell CSOM
- [Solved] Fix the “The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet, function” PowerShell error
- Complete basic operations using SharePoint REST endpoints
2 comments on “Instantly Fixed: Server relative urls must start with SPWeb.ServerRelativeUrl””