【问题标题】:How can I programmatically get the `recently visited sharepoint site` of current user in the tenant?如何以编程方式获取租户中当前用户的“最近访问的共享点站点”?
【发布时间】:2019-09-04 01:54:36
【问题描述】:

我想创建一个显示最近访问过的 SharePoint 站点的应用程序 (WebPart)。 我试过使用 MicrosoftGraph API,它给了我一个空值

这是我尝试过的(在 MS Graph Explorer 上检查)

网址:https://graph.microsoft.com/beta/me/insights/used

响应:“值”:[]

this.properties.graphClient.api("me/insights/used")
                          .version("beta")
                          .filter(`ResourceVisualization/Type eq 'Web'`)
                          .top(5)
                          .get((err, res: IRecentWebs) => {

           if (err) {
               return; 
           }

           if(res && res.value && res.value.length > 0) {
               this. _renderRecentSites(res.value);
           } else{
               alert('No site found');
           }
       });

并且还尝试将过滤器更改为

     ...
     .filter(`ResourceVisualization/containerType eq 'Site'`)
     ...

还是一无所获。我该怎么办?

【问题讨论】:

    标签: sharepoint microsoft-graph-api sharepoint-online


    【解决方案1】:

    此处列出了支持的容器类型https://docs.microsoft.com/en-us/graph/api/resources/insights-resourcevisualization?view=graph-rest-beta

    OneDriveBusiness
    Site
    Mail
    DropBox
    Box
    GDrive
    

    Web 不是受支持的容器类型。它是一种资源可视化类型。站点是受支持的容器类型。

    如果您转到 Graph Explorer,您可以在我们的示例用户帐户上看到这一点。 https://developer.microsoft.com/en-us/graph/graph-explorer?request=me/insights/used?$filter=ResourceVisualization/containerType eq 'Site'&method=GET&version=beta&GraphUrl=https://graph.microsoft.com

    如果您登录 Graph 资源管理器并运行相同的查询,您应该会在此处看到 OneDrive for Business 内任何活动使用的结果。你看到了吗?

    【讨论】:

    • 是的,如果我将 containerType 更改为 OneDriveBusiness,我会在 OneDrive for Business 中看到活动使用情况。
    • 这是正确的答案吗?如果是这样,您介意将此标记为已回答,请@Izle
    猜你喜欢
    • 2011-04-03
    • 2021-04-17
    • 1970-01-01
    • 2011-08-23
    • 2013-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多