【问题标题】:Using sharepoint search API, how to retrieve all documents within all sites within my sharepoint tenancy?使用 sharepoint 搜索 API,如何在我的 sharepoint 租用范围内检索所有站点内的所有文档?
【发布时间】:2019-11-21 21:53:17
【问题描述】:

我下面的代码 sn-p 是检索一个站点内一个文档库中的所有文档。

我希望能够检索我所有站点/租户内所有文档库中的所有文档。

  public getDocuments() {
    axios 
    .get("https://bpdev.sharepoint.com/sites/KIM/_api/lists/getbytitle('MyList2')/items?$select=*,FileRef",
            { params:{},
              headers: { 'accept': 'application/json;odata=verbose' }
            })
    .then(response => {
      this.setState({
        documents: response.data.d.results
      });
    })
    .catch(error => {
      console.log(error);
    });
  }

知道如何更新我的端点吗?

【问题讨论】:

    标签: sharepoint sharepoint-online


    【解决方案1】:

    您可以使用内容类型 id 来实现这一点。

    https://site.sharepoint.com/_api/search/query?querytext='contentclass:STS_Site contentclass:STS_Web ContentTypeId:0x0101*'
    

    这里的 0x0101*' 是文档内容类型 ID。如果我们创建新的内容类型,它将从 0x0101* 开始。

    【讨论】:

    • 我已经根据您的建议更新了我的终点,但是返回的 json/xml 不包含来自 KIM 站点的任何文档?
    • bpdev.sharepoint.com/_api/search/query?querytext='ContentTypeId:0x0101*'
    • 在查询文本中添加了另外 2 个属性,现在尝试添加它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多