Can anyone point me to an example or share some code on how to search multiple sites libraries with a single API Rest call? For example, I have a side called Document Archive and in that archive I have two document lists called Archive1 and Archive2. Here is the URL I am using to search:


If I run this from a console application I get 33 rows every time. But if I cut and paste this url into my web browser, I get only 2 results. If I go right to the document library and do the same search I get the same 2 results. So for some reason the rest calls from my console app are generating more results. So I suspect it has to do with the Path: statement. So two questions:

  1. How can I add more paths to this list? If I want to add path https://example.com/TS/EDMS/Archive/ to the path can I do this, or do I need to make two separate calls?
  2. Why am I getting more results from my console application than when I do a site search or paste the url into my browser?

Here is the code I am using to post the string to the site:

 HttpWebRequest endpointRequest = (HttpWebRequest)HttpWebRequest.Create(queryString);
            endpointRequest.Method = "GET";
            endpointRequest.Accept = "application/json; odata=verbose";
            endpointRequest.UseDefaultCredentials = true;
            HttpWebResponse endpointResponse = (HttpWebResponse)endpointRequest.GetResponse();
            //var _searchResults = SearchResult2(endpointResponse);

            Stream webStream = endpointResponse.GetResponseStream();
            StreamReader responseReader = new StreamReader(webStream);
            string response = responseReader.ReadToEnd();
            JObject jobj = JObject.Parse(response);

            var docReturnResult = new List<DocumentSearchResult>();

            JValue rowCount = (JValue)jobj["d"]["query"]["PrimaryQueryResult"]["RelevantResults"]["RowCount"];
            int loopCount = rowCount.ToObject<int>();

            for (int i = 0; i <= loopCount - 1; i++)
            {...process results here}
  • Do you want to limit your search to two libraries/list only..? Jul 18, 2018 at 5:19
  • For right now it will be libraries and lists only.
    – john
    Jul 18, 2018 at 14:36

3 Answers 3


Of you look at the documentation (https://docs.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-syntax-reference) you see that you can use AND, NOT and OR in your search query.

Another suggestion would be to use the SharePoint Search Query tool to fastly iterate: https://github.com/SharePoint/PnP-Tools/tree/master/Solutions/SharePoint.Search.QueryTool

Another option I sometimes use is to create a custom result source with the path as predifned queries.

  • I have the SharePoint Query Tool, but I don't know how use it to search multiple libraries. I'll take a look at the Link you sent for Docs.
    – john
    Jul 18, 2018 at 14:36

Try changing the URL to


Hope that helps


I appreciate all the responses and help. Here is how I "fixed" my problem (all my fault):


The problem I was having was the single quote after the querystring was in the wrong place. I had it after the search term and tried using the ampersand (&) or +AND+ as suggested, but once I moved the single quote to the end of the querystring is when started working. So everyone's answer was correct, it was my mistake of the single quote that was causing the problem. I hope this helps anyone else--watch the quotes!

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.