0

Our SharePoint 2016 site consists of 14 custom lists where each list has approximately 500 list items.

We wanted a way to query all 14 lists by PR NO which is common in all lists. We were looking for a solution implemented in JavaScript/jQuery.

I Have followed this solution to fetch all data from the 14 lists. response from server was taking too much time so we are not doing that approach.

How to get more than one SharePoint list using REST API?

1

You can do this using SharePoint Search. REST API also contains Search APIs for SharePoint.

Create a result source by adding paths of all your lists in the query builder (also specify content type contains item). Check this article for creating a result source.

Your query builder should look like this. enter image description here

Check if the results are as desired and then you can use the Search API referring to the Microsoft documentation here.

To get results from result source using search rest api, I used the following url

https://spdev.sharepoint.com/sites/SPTeam/_api/search/query?querytext='*'&sourceid='46cac739-2506-4f58-bef1-d4857548cf0b'

here instead of querytext='*', you can add your PR NO. For Example, querytext='PR123123'

To build Search Rest API Queries, you can use this free tool -> SharePoint Search Query Tool. This tool is very useful in creating SharePoint Search REST API URLs.

| improve this answer | |
  • Thank you very much sir, ill test it out tomorrow in work and get back to you. – Jilo Nov 27 '19 at 21:59
  • Hello @harshal gite sorry for ghosting your reply for a couple of days, im having issues with the sharepoint search API i tried multiple endpoints that related to the search api for example /_api/search/query?querytext='sharepoint it is giving me the following error: {"error":{"code":"-1, Microsoft.Office.Server.Search.REST.SearchServiceException","message":{"lang":"en-US","value":"An unknown error occurred."}}} do you know what could be the reason? – Jilo Dec 1 '19 at 8:35
  • this is the exact issue i get sharepoint.stackexchange.com/questions/256757/… – Jilo Dec 1 '19 at 8:49
  • just try tenant/_api/search/query?querytext='*' once. Let me know if you get any errors. Are you the SharePoint admin? I mean do you have access to the SharePoint admin center? – harshal gite Dec 1 '19 at 9:58
  • I tried that, im still getting the same error, No i do not have Access the SharePoint admin center. – Jilo Dec 1 '19 at 10:04

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.