SharePoint Server relative urls must start with SPWeb.ServerRelativeUrl csom

In this SharePoint PnP tutorial, We will discuss the solution to an error as “SharePoint Server relative urls must start with SPWeb.ServerRelativeUrl“.

I recently worked with PnP SharePoint ASP.NET Web Application in Visual Studio 2017. There, I have added a Content Search Web Part using CSOM. To add this web part, You have to retrieve the Page URL. I was adding this page URL as [“/Pages/WebPartPageName.aspx”].

While running this CSOM code, an error occurred “SharePoint Server relative urls must start with SPWeb.ServerRelativeUrl“. You can see the error message in the below screenshot.

server relative urls must start with spweb.serverrelativeurl csom
server relative urls must start with spweb.serverrelativeurl csom

SharePoint Server relative urls must start with SPWeb.ServerRelativeUrl

The Solution of this above error is: You should pass the Server Relative URL as “/sites/SiteName/Pages/WebPartPageName.aspx “. Once you will pass this type of Server relative URL Path and again run the code, then it will execute and give the appropriate result.

Here in this SharePoint PnP tutorial, We discussed the solution of an error as “SharePoint Server relative urls must start with SPWeb.ServerRelativeUrl“. By using the above solution, You can overcome this type of issue.

You may also like the following tutorials:

>