What is the best way to loop through all the document libraries in a web application using REST API.

I need to find the particular document based on the ID in a whole web application. I don't want to loop through all the document libraries one by one. is there any better way to achieve this using REST?

  • You are not aware in which document library this document is?
    – Asad Refai
    Commented May 20, 2016 at 5:50
  • No.it can be in any document library Commented May 20, 2016 at 5:53
  • ID is the normal IDs like 1,2,3 or its generated via Doc ID service?
    – Asad Refai
    Commented May 20, 2016 at 5:54
  • its generated via Doc ID service Commented May 20, 2016 at 5:55

1 Answer 1


IDs of documents generated by Doc ID service is something like N3SITE-424387581-13.

If we try to break the Id N3SITE-424387581-13 we can notice that

  1. N3SITE: is the prefix which we have in Document ID settings.
  2. 424387581: Is the random number generated by SharePoint.
  3. 13: is nothing but the normal ID of a document.

N3SITE and 13 are quite easy to understand and they are in our control to identify which site collection. But 424387581 puzzle us, and also from site collection which library it belongs we would also like to know that.

424387581 is nothing but the unique Id given to a document library. but from where we got to know it?

Cracking down curious case of 424387581: Open your office 365 site collection in SharePoint Designer. From ribbon control click on Site Options which is a property bag. Find the property docid_msft_hier_listidx, this contains the unique id for all the document libraries.

Refer find source of a record in record centre using Document ID service

How to that in REST: As you have mentioned in comments, that you have the Document ID. You can follow below steps

  1. Extract out the middle part of the ID, i.e. 424387581
  2. Find out how to use REST to query the property bag and get value of key=424387581. Refer value in web property bag using REST API
  3. From step 2 you will get the GUID of the document library.
  4. Query the document library with the ID(the last part of Doc ID). And thats it.
  • Do you know how to query property bag to get value of key? Commented May 20, 2016 at 6:33
  • No never done that. But get all the properties, I think it will be in xml format then query xml.
    – Asad Refai
    Commented May 20, 2016 at 6:35
  • ok thanks for the answer. i will try this out and let you know Commented May 20, 2016 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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