首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用v1.0TeamsGraphAPI创建时,获取通道名称不能为空

使用v1.0TeamsGraphAPI创建时,获取通道名称不能为空
EN

Stack Overflow用户
提问于 2021-02-19 15:56:14
回答 2查看 458关注 0票数 0

我们使用Microsoft "POST team /v1.0“以编程方式创建Microsoft。此端点允许创建具有预定义内容的团队,如设置、应用程序、通道和选项卡。然而,当我们试图创建一个带有预定义选项卡的团队时,我们开始面临今天的问题。这个问题可以很容易地在中再现。这就是样例请求的样子:

代码语言:javascript
复制
POST https://graph.microsoft.com/v1.0/teams

{
    "template@odata.bind": "https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
    "visibility": "Private",
    "displayName": "Sample Engineering Team",
    "description": "This is a sample engineering team, used to showcase the range of properties supported by this API",
    "channels": [
        {
            "displayName": "Announcements ",
            "isFavoriteByDefault": true,
            "description": "This is a sample announcements channel that is favorited by default. Use this channel to make important team, product, and service announcements."
        },
        {
            "displayName": "Training ️",
            "isFavoriteByDefault": true,
            "description": "This is a sample training channel, that is favorited by default, and contains an example of pinned website and YouTube tabs.",
            "tabs": [
                {
                    "teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.web')",
                    "displayName": "A Pinned Website",
                    "configuration": {
                        "contentUrl": "https://learn.microsoft.com/microsoftteams/microsoft-teams"
                    }
                },
                {
                    "teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.youtube')",
                    "displayName": "A Pinned YouTube Video",
                    "configuration": {
                        "contentUrl": "https://tabs.teams.microsoft.com/Youtube/Home/YoutubeTab?videoId=X8krAMdGvCQ",
                        "websiteUrl": "https://www.youtube.com/watch?v=X8krAMdGvCQ"
                    }
                }
            ]
        },
        {
            "displayName": "Planning  ",
            "description": "This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu.",
            "isFavoriteByDefault": false
        },
        {
            "displayName": "Issues and Feedback ",
            "description": "This is a sample of a channel that is not favorited by default, these channels will appear in the more channels overflow menu."
        }
    ],
    "memberSettings": {
        "allowCreateUpdateChannels": true,
        "allowDeleteChannels": true,
        "allowAddRemoveApps": true,
        "allowCreateUpdateRemoveTabs": true,
        "allowCreateUpdateRemoveConnectors": true
    },
    "guestSettings": {
        "allowCreateUpdateChannels": false,
        "allowDeleteChannels": false
    },
    "funSettings": {
        "allowGiphy": true,
        "giphyContentRating": "Moderate",
        "allowStickersAndMemes": true,
        "allowCustomMemes": true
    },
    "messagingSettings": {
        "allowUserEditMessages": true,
        "allowUserDeleteMessages": true,
        "allowOwnerDeleteMessages": true,
        "allowTeamMentions": true,
        "allowChannelMentions": true
    },
    "discoverySettings": {
        "showInTeamsSearchAndSuggestions": true
    },
    "installedApps": [
        {
            "teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.vsts')"
        },
        {
            "teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('1542629c-01b3-4a6d-8f76-1938b779e48d')"
        }
    ]
}

这就是错误响应包括的内容:

代码语言:javascript
复制
[
   "message":"Tabs with duplicate DisplayName are not allowed.",
   "errorCode":"Unknown",
   "message":"'Channel Name' must not be empty.",
   "errorCode":"Unknown",
   "message":"'Channel Name' should not be empty.",
   "errorCode":"Unknown",
   "message":"'Channel Name' must not be empty.",
   "errorCode":"Unknown",
   "message":"'Channel Name' should not be empty.",
   "errorCode":"Unknown"
]

如果JSON对象不包含任何选项卡配置,POST v1.0/teams端点将正确工作。在这里,我们讨论了测试场景:

  • 后beta/teams
  • POST v1.0/teams
  • 委托许可
  • 申请许可

有什么想法?

EN

回答 2

Stack Overflow用户

发布于 2021-02-19 19:50:34

我还不能测试这个,但是我怀疑您的选项卡json应该有一个displayName属性而不是name。因为我在这里没有看到一个name属性:https://learn.microsoft.com/en-us/graph/api/resources/teamstab?view=graph-rest-1.0

所以您的选项卡部分应该是:

代码语言:javascript
复制
"tabs":[
   {
      "teamsApp@odata.bind":"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.web')",
      "displayName":"A Pinned Website",
      "configuration":{
         "contentUrl":"https://learn.microsoft.com/microsoftteams/microsoft-teams"
      }
   },
   {
      "teamsApp@odata.bind":"https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.youtube')",
      "displayName":"A Pinned YouTube Video",
      "configuration":{
         "contentUrl":"https://tabs.teams.microsoft.com/Youtube/Home/YoutubeTab?videoId=X8krAMdGvCQ",
         "websiteUrl":"https://www.youtube.com/watch?v=X8krAMdGvCQ"
      }
   }
]

编辑:,我只是试了一下,也没能让它工作。

但是,我找到了一个解决办法,首先在没有选项卡部分的情况下发布完整的请求,然后通过将选项卡单独添加到https://graph.microsoft.com/v1.0/teams/{team-id}/channels/{channel-id}/tabs

我手动执行此操作的方式(我确信有更好的方法可以检索到team和channel-id):

  1. 在没有选项卡部分的情况下发布请求。
  2. 使用GET https://graph.microsoft.com/v1.0/me/joinedTeams检索创建的团队的id。
  3. 调用GET https://graph.microsoft.com/v1.0/teams/{team-id}/channels检索通道。
  4. 我将下面的选项卡段发布到https://graph.microsoft.com/v1.0/teams/{team-id}/channels/{channel-id}/tabs,并检索到一个201个创建的响应。
代码语言:javascript
复制
{
    "teamsApp@odata.bind": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps('com.microsoft.teamspace.tab.web')",
    "displayName": "A Pinned Website",
    "configuration": {
        "contentUrl": "https://learn.microsoft.com/microsoftteams/microsoft-teams"
    }
}
票数 0
EN

Stack Overflow用户

发布于 2021-02-28 17:06:29

这是一个与带有选项卡的通道的有效负载有关的问题,而不是namedisplayName属性。它已经在MS图v1.0中得到了修正。

还请注意,选项卡上的namedisplayName都可以工作,但文档中的属性是displayName,所以我建议您切换到该属性,而不是name

这是一个我自己测试过的有效载荷的样本。文档中的示例应该在选项卡配置上使用displayName

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66280832

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档