60,597 total views, 9 views today
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.

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="https://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:
https://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:
https://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
https://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”in reading web part properties! – SharePoint Online (Microsoft 365)”