private static async Task ExecuteSearchQuery(List <SearchResult> results, CapabilityDiscoveryResult dcr, string sharePointToken, string query) { HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + sharePointToken); client.DefaultRequestHeaders.Add("Accept", "application/json; odata=verbose"); using (HttpResponseMessage response = await client.GetAsync(new Uri(dcr.ServiceEndpointUri + query, UriKind.Absolute))) { if (response.IsSuccessStatusCode) { XElement root = SearchModel.Json2Xml(await response.Content.ReadAsStringAsync()); var items = root.Descendants("RelevantResults").Elements("Table").Elements("Rows").Elements("results").Elements("item"); foreach (var item in items) { //loop through the properties returned for this item var newItem = new SearchResult(); foreach (var prop in item.Descendants("item")) { if (prop.Element("Key").Value == "Title") { newItem.Title = prop.Element("Value").Value; } else if (prop.Element("Key").Value == "Path") { newItem.Path = prop.Element("Value").Value; } else if (prop.Element("Key").Value == "SiteLogo") { newItem.SiteLogo = prop.Element("Value").Value; } else if (prop.Element("Key").Value == "contentclass") { newItem.ContentClass = prop.Element("Value").Value; } } //only return site collections in primary domain...not the onedrive or public domains //this would probably be better placed in the original search query if (newItem.Path.ToLower().Contains(dcr.ServiceResourceId.ToLower())) { results.Add(newItem); } } } } }