[Fixed] Server relative urls must start with SPWeb.ServerRelativeUrl"in reading web part properties!

Instantly Fixed: Server relative urls must start with SPWeb.ServerRelativeUrl”in reading web part properties! – SharePoint Online (Microsoft 365)

2 comments

 59,473 total views,  3 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"in reading web part properties!:
“Server relative URLs must start with SPWeb.ServerRelativeUrl” in reading web part properties!:

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!:?

Server relative urls must start with SPWeb.ServerRelativeUrl"in reading web part properties!
[Fixed] 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

System.Argument Exception in Server relative urls must start with SPWeb.ServerRelativeUrl error
System.Argument Exception in Server relative URLs must start with SPWeb.ServerRelativeUrl error

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.

GetFolderByServerRelativeUrl - Server relative urls must start issue fixed
GetFolderByServerRelativeUrl – Server relative URLs must start issue fixed

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:

 

 

 

About Post Author

2 comments on “Instantly Fixed: Server relative urls must start with SPWeb.ServerRelativeUrl”in reading web part properties! – SharePoint Online (Microsoft 365)”

Do you have a better solution or question on this topic? Please leave a comment