In this SharePoint PnP tutorial, We will discuss the solution of an error as “SharePoint Server relative urls must start with SPWeb.ServerRelativeUrl“.
Recently, I was working 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 I was running this CSOM code, an error occurred as “SharePoint Server relative urls must start with SPWeb.ServerRelativeUrl“. You can see the error message in below screenshot.
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.
You may like following SharePoint PnP csom tutorials:
- Delete All items from the SharePoint List using PnP core CSOM Library Programmatically
- Create Folder and Subfolder in SharePoint Document Library using PnP Core CSOM Library
- Term update failed because of save conflict SharePoint Online
- SharePoint Online: Create an indexed column in a list Programmatically using CSOM .Net managed object model code using visual studio 2017/2015
- [Solved] the request message is too big. the server does not allow messages larger than 2097152 bytes in SharePoint online visual studio 2015/2017 workflow
- You cannot change moderation status and set other item properties at that same time SharePoint online csom
- Getting Started with PnP PowerShell – SharePoint 2013/2016/SharePoint Online
- [Solved] Current site is not a tenant administration site error in SharePoint Online PowerShell
- Could not load file or assembly ‘Microsoft.AI.Web’ or one of its dependencies. The system cannot find the file specified.
- the list is too large to save as a template SharePoint 2016
Here in this SharePoint PnP tutorial, We discussed the solution of an error as “SharePoint Server relative
Hello Everyone!! I am Bhawana a SharePoint MVP and having about 10+ years of SharePoint experience as well as in .Net technologies. I have worked in all the versions of SharePoint from wss to Office 365. I have good exposure in Customization and Migration using Nintex, Metalogix tools. Now exploring more in SharePoint 2016 🙂 Hope here I can contribute and share my knowledge to the fullest. As I believe “There is no wealth like knowledge and no poverty like ignorance”