My google searches have all led to dead ends.

Is there a way to retrieve the durable link code for a document using the REST API?

When you copy a link in the GUI, it takes the form of:-


I would like to know how to retrieve the d=.... part, using the SharePoint REST API, given I have the ID of the library item (e.g 847) and the library location details etc.


It is present in the LinkingUrl property of the file in a document library.

So, to get that value, you need to modify the endpoint as below:


Reference - SP Durable links

  • I had seen that page, however I couldn't resolve how to apply it to an endpoint. – John7766 Sep 6 '18 at 14:32
  • I get a response from the server, however it does not appear to contain the required field. (It does not contain a value that matches the string obtainable from the SP GUI for the same Document Set in the same Document Library) Nor does it contain a node 'LinkingURL'. Any other hints to what I might be doing wrong? – John7766 Sep 6 '18 at 14:36
  • The above code works for Files. To make it work for folder or document sets, you can use https://mysite.sharepoint.com/sites/mysite/_api/web/lists/getbytitle('mylibrary')/_api/web/lists/getbytitle('Documents')/items(32)?$select=*,Folder/UniqueId&$expand=Folder. It will give you the uniqueId property of the document set which will be the value you can use for d=... section ! – Gautam Sheth Sep 6 '18 at 14:48
  • That's great - thank you. The REST API is now returning a <d:UniqueId> node, with a value similar to the GUI's. Is it safe to assume that I should always pre-pend a w, and strip out the dashes (-) to arrive at the same link the GUI would supply? – John7766 Sep 6 '18 at 15:35
  • Also, BTW, I believe there was a surplus /_api/web/lists/getbytitle('Documents') in the URI you posted in your comment, above - I ended up using https://mysite.sharepoint.com/sites/mysite/_api/web/lists/getbytitle('mylibrary')/items(32)?$select=*,Folder/UniqueId&$expand=Folder – John7766 Sep 6 '18 at 15:40

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.