Getting error message "Server relative urls must start with SPWeb.ServerRelativeUrl"

%3CLINGO-SUB%20id%3D%22lingo-sub-2541415%22%20slang%3D%22en-US%22%3EGetting%20error%20message%20%22Server%20relative%20urls%20must%20start%20with%20SPWeb.ServerRelativeUrl%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2541415%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20have%20written%20a%20code%20of%20WebApi%20to%20load%20SharePoint%20folders%20using%20client%20Context.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWe%20have%20written%20following%20code%20to%20LOAD%20SharePoint%20folders.%3CBR%20%2F%3EFolder%20folder%20%3D%20clientContext.Site.RootWeb.GetFolderByServerRelativeUrl(relativeURL)%3B%3CBR%20%2F%3EclientContext.Load(folder)%3B%3CBR%20%2F%3EclientContext.ExecuteQuery()%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAND%20we%20are%20getting%20below%20error%20when%20the%20we%20run%20the%20Execute%20method.%20%22Server%20relative%20urls%20must%20start%20with%20SPWeb.ServerRelativeUrl%22.%20Please%20help%20us%20to%20resolve%20the%20same.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDoes%20anyone%20have%20any%20ideas%20about%20this%20error%3F%20Any%20help%20would%20be%20greatly%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2541415%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAPIs%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor

Hi,

 

We have written a code of WebApi to load SharePoint folders using client Context.

 

We have written following code to LOAD SharePoint folders.
Folder folder = clientContext.Site.RootWeb.GetFolderByServerRelativeUrl(relativeURL);
clientContext.Load(folder);
clientContext.ExecuteQuery();

 

AND we are getting below error when the we run the Execute method. "Server relative urls must start with SPWeb.ServerRelativeUrl". Please help us to resolve the same.

 

Does anyone have any ideas about this error? Any help would be greatly appreciated.

 

Thanks.

0 Replies