Is it possible to work with the document library with UniqueID/Guids rather than using GetFileByServerRelativeUrl?

Say if I wanted to upload a file to a folder, could this be done using the Unique Id instead of the relative path?


2 Answers 2


Sure, SP.Web object in SharePoint 2013/Online exposes the following methods:

1) Web.GetFolderById

REST endpoint: /_api/web/GetFolderById('<folder unique id>')

2) Web.GetFileById

REST endpoint: /_api/web/GetFileById('<file unique id>')

  • 2
    That just saved my life, thanks! Just one comment though, for SharePoint newbies like me, the base url has to be the one for the site. Like myorg.sharepoint.com/the-site-name/_api/web/….
    – Francisco
    May 26, 2015 at 11:10
  • 1
    Thanks a million! i've been trying to delete files by filename using "/_api/web/getfilebyserverrelativeurl('" + fileToDelete +"')" It works in most cases but i couldn't figure out how to process special characters like #. Your method works everytime!
    – Ice Cube
    Feb 25, 2020 at 23:20
  • can't find this GetFileById in the CSOM C# dll. is this available only in REST API and SSOM ? Mar 31, 2020 at 8:06

You can get the document library using the title and then perform the upload

_api/web/lists/getByTitle(@TargetLibrary)/RootFolder/Files/add(url=@TargetFileName,overwrite='true')?@TargetLibrary='LibraryName'&@TargetFileName='Target File Name'


  • Thanks. Is it possible to reference folders by the Guid instead of using the path?
    – Webfort
    Oct 28, 2014 at 8:12

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.