How can we get data from multiple list by using sharepoint REST API in one call . I: want to get data and also want to use multiple list for searching data too. Is it possible to do this in one call if "YES" then how and if "NO" then what are the best solutions for getting data??
Thanks in advance..
解决方案First of all, SharePoint REST does not support request batching like CSOM does. That makes it impossible to make multiple REST calls in a single round trip to the service.
The good news that according to Office 365 business roadmap the feature:
CSOM Batching for Apps for SharePointThis feature allows support for $batch requests in SharePoint's OData REST services. This allows apps to make multiple REST calls in a single round trip to the service.
is already in Development state. Hurray! Thanks to the Office Developer Platform UserVoice for that and specifically to Andrew Connell for creating a feature request
From another hand, Search Query API could be used for querying multiple lists, for example the following search query:
contentclass:STS_ListItem AND ContentType:Taskwill return all Task items.
JavaScript ExampleThe following example demonstrates how to utilize Search API using REST endpoint:
function searchTaskItems(webUrl,success, failure) { var url = webUrl + "/_api/search/query?querytext='contentclass:STS_ListItem AND ContentType:Task'"; $.ajax({ url: url, method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { success(data.d.query); }, error: function (data) { failure(data); } }); } //print tasks searchTaskItems(_spPageContextInfo.webAbsoluteUrl, function(query){ var resultsCount = query.PrimaryQueryResult.RelevantResults.RowCount; for(var i = 0; i < resultsCount;i++) { var row = query.PrimaryQueryResult.RelevantResults.Table.Rows.results[i]; var taskName = row.Cells.results[3].Value; console.log(taskName); } }, function(error){ console.log(JSON.stringify(error)); } );
更多推荐
在一次 Ajax 调用中从多个列表共享点 REST API 中获取数据
发布评论