In this SharePoint tutorial, I will explain how to resolve the error “Server relative urls must start with spweb.serverrelativeurl” that occurs while working with CSOM SharePoint.
Server relative URLs must start with spweb.serverrelativeurl
Recently, I was working with an ASP.NET web application using Visual Studio. 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.” The error message is shown in the screenshot below.

The Solution to the above error is: You should pass the Server Relative URL as “/sites/SiteName/Pages/WebPartPageName.aspx.” Once you pass this type of server-relative URL Path and rerun the code, it will execute and provide the appropriate result.
This is how to fix the error: Server relative URLs must start with spweb.serverrelativeurl that comes while working with CSOM SharePoint.
You may also like:
- SharePoint Rest API
- SharePoint Server Object Model Tutorial
- Error=Value=QuotaExceeded in SharePoint
- http error 400. the size of the request headers is too long

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.