【问题标题】:Create website Tab in Teams using MS Graph Java使用 MS Graph Java 在 Teams 中创建网站选项卡
【发布时间】:2021-07-29 13:54:47
【问题描述】:

我正在尝试使用 Graph Api 在我的 Microsoft Teams 频道中创建一个选项卡,但我一直收到有关程序以非零退出值 1 完成的错误。

public static void createTab(){
     if (graphClient == null) throw new NullPointerException(
             "Graph client has not been initialized. Call initializeGraphAuth before calling this method");

     TeamsTab newTab = new TeamsTab();
     newTab.configuration.contentUrl = "https://www.google.com/?client=safari";
     newTab.configuration.entityId = null;
     newTab.configuration.removeUrl = null;
     newTab.configuration.websiteUrl = "https://www.google.com/?client=safari";
     newTab.displayName = "New Website Tab";

     //Post New Tab
     graphClient.teams("teams-id").channels("channel-id")
             .tabs().buildRequest().expand("teamsApp").post(newTab);

 }

This is my code, can someone please have a look?

【问题讨论】:

    标签: java microsoft-graph-api microsoft-graph-sdks microsoft-graph-teams


    【解决方案1】:

    只是为了它,试试这个:

    public void createTab() {
    
        if (graphClient == null) throw new NullPointerException(
                 "Graph client has not been initialized. Call initializeGraphAuth before calling this method");
    
        TeamsTab newTab = new TeamsTab();
        User me = newTab.graphClient.getMe().buildRequest().get();
            newTab.configuration.contentUrl = "https://www.google.com/?client=safari";
            newTab.configuration.entityId = null;
            newTab.configuration.removeUrl = null;
            newTab.configuration.websiteUrl = "https://www.google.com/?client=safari";
            newTab.displayName = "New Website Tab";
    
            //Post New Tab
            newTab.graphClient.getMe().teams("teams-id").channels("channel-id")
                    .getTab().buildRequest().post();
    
        }
        ```
    

    【讨论】:

    • "teamsApp@odata.bind" 我不确定如何将其添加到我的代码中。你发现我的代码有什么问题吗?我对 Graph 很陌生
    • 我正在查看它。可能需要一段时间。
    • 我不确定代码本身就是问题所在。看来您需要使用以下命令请求将选项卡插入频道:POST /teams/{team-id}/channels/{channel-id}/tabs 一旦该步骤完成,您发送请求(您编写的代码),如果成功,他们将为您添加选项卡并您将收到响应消息。
    • 是的,但我正在使用 Java 进行开发,所以我使用了 graphClient.teams("teamsid").channels("channel-id").tabs().buildRequest().expand("teamsApp" ).post(newTab);
    • 但我不确定这是否是正确的方法,因为文档只显示 POST /teams/{team-id}/channels/{channel-id}/tabs
    猜你喜欢
    • 1970-01-01
    • 2021-03-24
    • 2021-04-16
    • 2010-12-31
    • 2021-02-12
    • 1970-01-01
    • 2022-07-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多