In site collection features there is an option to enable Document ID Service. After doing this, whenever a document is uploaded to a document library, a unique document id that is a link to the doc is provided as a column. I would like to use the SharePoint API to retrieve this document only by this id.

Doing an API call like this works to some extent (using the internal name of the document ID column):

<url_SP_Site>/_api/web/lists/getbytitle('[Name_Document_Library]')/items?$select=Id&$filter=OData__dlc_DocId eq '[Id_you_search_for]'

In this type of format, the call only works if the document is in a document library with a specific name (if user has the file in a library name 'New Lib' it won't work).

Is there a way to get a document by its Id from ANY library in SharePoint?

In that way the document does not have to be uploaded into a library with a specific name. Additionally, the above API call does not return any of the column information from the document, it only returns the ID.

Can anyone modify the call so that the return includes ALL of the column information?

Any help would be greatly appreciated!


To get the document without providing document library name, use this:


Source: Rest API to get a file using the GUID

  • I can see from that article that this is a problem others have had. Unfortunatly the solution did not work, the parem of that method requires a GUID, not sure why the author said could repro with Sarepoint's OData__dlc_DocId column value, the return throws an error saying that a 32 digit GUID is required as a parameter – Kyle Trent Feb 11 at 6:33

You could use SharePoint search rest api to achieve this. Use DocId=[Id_you_search_for] in the api:



If you want to get all the column information, you need to remove the select parameter in the endpoint:

<url_SP_Site>/_api/web/lists/getbytitle('[Name_Document_Library]')/items?$filter=OData__dlc_DocId eq '[Id_you_search_for]'
  • While this returns something, none of the information seems to be relevant, there is no column data nor any other information I could use to make api requests to get the column data (by columns I mean the fields in the document details pane where the file exists in the Sharepoint document lib) – Kyle Trent Feb 11 at 6:28
  • To get all the column information, check my update answer. In this way, we cannot get a document by its Id from ANY library in SharePoint. It's in specific list/library. – Michael Han_MSFT Feb 12 at 7:38
  • That did the trick! Thanks :) – Kyle Trent Feb 25 at 18:43
  • You could accept my answer if it helps you. – Michael Han_MSFT Mar 8 at 1:16

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.