我们使用Microsoft "POST team /v1.0“以编程方式创建Microsoft。此端点允许创建具有预定义内容的团队,如设置、应用程序、通道和选项卡。然而,当我们试图创建一个带有预定义选项卡的团队时,我们开始面临今天的问题。这个问题可以很容易地在中再现。这就是样例请求的样子:
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')"
}
]
}这就是错误响应包括的内容:
[
"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端点将正确工作。在这里,我们讨论了测试场景:
有什么想法?
发布于 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
所以您的选项卡部分应该是:
"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):
{
"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"
}
}发布于 2021-02-28 17:06:29
这是一个与带有选项卡的通道的有效负载有关的问题,而不是name或displayName属性。它已经在MS图v1.0中得到了修正。
还请注意,选项卡上的name和displayName都可以工作,但文档中的属性是displayName,所以我建议您切换到该属性,而不是name。
这是一个我自己测试过的有效载荷的样本。文档中的示例应该在选项卡配置上使用displayName。
https://stackoverflow.com/questions/66280832
复制相似问题