简体   繁体   English

所有网站集中的SharePoint 2013 REST API GetItems

[英]SharePoint 2013 REST API GetItems in all site collection

I use this POST request for get items 我使用此POST请求获取商品

var url="/_api/web/lists/getByTitle('Documents')/GetItems(query=@v1)?$select=Title,FileRef&@v1={\"ViewXml\":\"<View><Query><Where><Eq><FieldRef%20Name='societe'/><Value%20Type='TaxonomyFieldType'>"+currentCompany+"</Value></Eq></Where></Query></View>\"}";
       console.log(url);
        return $http({
            method: 'POST',
            url: "/_api/web/lists/getByTitle('Documents')/GetItems(query=@v1)?$select=Title,FileRef&@v1={\"ViewXml\":\"<View><Query><Where><Eq><FieldRef%20Name='societe'/><Value%20Type='TaxonomyFieldType'>"+currentCompany+"</Value></Eq></Where></Query></View>\"}",
            headers: {
                'Accept': 'application/json;odata=verbose'
                , 'X-RequestDigest': $('#__REQUESTDIGEST').val()
            }
        });

That works but I would like to get this items in all site collection and not just in Documents List. 那行得通,但我想在所有网站集中而不只是在“文档列表”中获得此项目。

Is it possible ? 可能吗 ?

There is something called SPSiteDataQuery in the Server Side Object Model which allows to query for content across the whole site collection - if you work in OnPrem, you might be able to utilize that. 服务器端对象模型中有一个称为SPSiteDataQuery的东西,它可以查询整个网站集中的内容-如果您在OnPrem中工作,则可以利用它。 Unfortunately, there is no equivalent for this functionality on the client side (so in JSOM, CSOM and REST). 不幸的是,客户端上没有等效的功能(因此在JSOM,CSOM和REST中)。

However, depending on your use case you can might consider using SharePoint Search. 但是,根据您的用例,您可以考虑使用SharePoint搜索。 Keep in mind, though, that it might not return the results you want and that changes made to the items will not be instantly visible in the results (it might even take a couple of hours for the index to be updated). 不过请记住,它可能不会返回您想要的结果,并且对项目所做的更改将不会立即在结果中可见(更新索引可能要花费几个小时)。

More on SPSiteDataQuery: SPSiteDataQuery Share Point Example 有关SPSiteDataQuery的更多信息: SPSiteDataQuery共享点示例

Linked thread on SharePoint Stack Exchange: Can we use SPSiteDataQuery in JSOM OUT OF BOX? SharePoint Stack Exchange上的链接线程: 我们可以在JSOM中使用SPSiteDataQuery吗?

More about Search: Using the SharePoint search Query APIs 有关搜索的更多信息: 使用SharePoint搜索查询API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM