Get Document Path (ServerRelativeUrl) in SharePoint 2013 using REST API


Suppose we have a document in document library in SharePoint 2013 inside sub folders

Ex: /En/Documents/Folder1/Folder2/stats.png

Now, using REST API we need to get the Server Relative Url (ServerRelativeUrl) by the document ID.

Solution

The REST API url will be: http://<server name>/<sub site>/_api/web/lists/getbytitle(‘Documents’)/items(‘<Document ID>’)/File

In my case it will be : http:// <server name>/En/_api/web/lists/getbytitle(‘Documents’)/items(‘5‘)/File

Result

Advertisements

5 thoughts on “Get Document Path (ServerRelativeUrl) in SharePoint 2013 using REST API

  1. Hi Mostafa Absy, Thanks for your post, i followed the post, however couldnt retrieve any item from the document library.

    It says: List “ABC” doesnt exist at site with URL ‘site/subsite’.

    Thanks,
    Ramii

  2. Thanks Mostafa Absy, it is now working, have overlooked it earlier

    I have one more question here if you can answer that would be helpful, how do you identify getbytitle here:
    My scenario, i have two libraries with DocLibName1 (Archived), DocLibName2 ( names are from URL). How to construct end point

    http://Server/sites/Subsite/_api/web/lists/getbytitle('DocLibName1‘)/items?$select=Title,Status — this works, however
    http://Server/sites/Subsite/_api/web/lists/getbytitle('DocLibName2‘)/items?$select=Title — doesnot work.

    Any idea?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s