0

I'm tring to get the file by relative URL . I"m usig sharepoint onligne . and i get this error:

Server relative urls must start with SPWeb.ServerRelativeUrl

here is the code:

$web = $ctx.Web
  $ctx.Load($web)
  $ctx.ExecuteQuery()
  $PageLayoutName = $pageLayoutContentType
  $items = $web.GetFileByServerRelativeUrl($PageLayoutName)
  $ctx.Load($items)
  $ctx.ExecuteQuery()
  • 1
    what values are you using in $pageLayoutContentType and $PageLayoutName ? It needs to be relative url like /sites/test/_catalogs/master/mypagelayout.aspx – Gautam Sheth Nov 22 '17 at 9:20
1

You can check a page layout server relative url with Rest API, for example, get a pagelayout server relative url in Pages Library:

http://sp/sites/dev/_api/web/lists/getbytitle('Pages')/items(1)/file

enter image description here

And use this value in $web.GetFileByServerRelativeUrl method

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.