简体   繁体   English

无法使用 Graph API 向 Microsoft 团队频道发布消息

[英]Unable to post message to Microsoft teams channel using Graph API

I am trying post message to Microsoft teams channel using Graph API but bot no luck.我正在尝试使用 Graph API 向 Microsoft 团队频道发布消息,但机器人没有运气。

First I got Bearer token by making below call.首先,我通过拨打以下电话获得了不记名令牌。

curl --location --request POST 'https://login.microsoftonline.com/22109ccf-0021-48af-947a-11111111111/oauth2/v2.0/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: x-ms-gateway-slice=estsfd; stsservicecookie=estsfd; fpc=ApGgHx8qh5hBlL_RviIqR3XYPIX9AQAAADMMeNgOAAAA' \
--data-urlencode 'scope=https://graph.microsoft.com/.default' \
--data-urlencode 'client_id={client_id}' \
--data-urlencode 'client_secret={client_secret}' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'code=' \
--data-urlencode 'redirect_uri=https://localhost:8080'

Using bearer token got in previous call to post message to teams channel.使用先前调用中获得的不记名令牌将消息发布到团队频道。 but receiving Unauthorized error , I have added below permissions但收到Unauthorized错误,我添加了以下权限

Teamwork.Migrate.All (App) Teamwork.Migrate.All (App)

Content-type: application/json

{
  "body": {
    "content": "Hello World"
  }
}

I tried using explore https://developer.microsoft.com/en-us/graph/graph-explorer but getting MethodNotAllowed error.我尝试使用 explore https://developer.microsoft.com/en-us/graph/graph-explorer但收到MethodNotAllowed错误。

Is it possible to post message to MS teams channel by using Graph API ?In documentation it says we can https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-1.0&tabs=http .是否可以使用 Graph API 将消息发布到 MS 团队频道?在文档中它说我们可以https://docs.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest -1.0&tabs=http

Could you please check your token here and confirm if you see all the necessary permissions in it.您能否在这里检查您的令牌并确认您是否看到其中的所有必要权限。

As per documentation, here is the list of permissions supported.根据文档,这里是支持的权限列表。 在此处输入图片说明

Please make sure, if you are using permission 'ChannelMessage.Send' it is obtained using delegated context token as Application context token is currently not supported.请确保,如果您使用“ChannelMessage.Send”权限,它是使用委托上下文令牌获得的,因为当前不支持应用程序上下文令牌。

Hope this helps.希望这可以帮助。 Thanks!谢谢!

I'm facing similar issue while trying to send message to teams channel via postman.我在尝试通过邮递员向团队频道发送消息时遇到了类似的问题。 I added ChannelMessage.Send permission to my app in Azure Ad account.我在 Azure 广告帐户中为我的应用添加了 ChannelMessage.Send 权限。 But when I create another token and test it using the link I don't see the permission added.但是当我创建另一个令牌并使用链接测试它时,我没有看到添加的权限。 How long does it take for the permission to be added to an account?权限添加到帐户需要多长时间?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Graph API 删除 Microsoft Teams 频道消息 - Delete a Microsoft Teams channel message using the Graph API 使用 Microsoft Graph API C# 向 Microsoft Teams 频道发送聊天消息 - Sending a chat message to a microsoft Teams channel using Microsoft Graph API C# 使用 Graph API 在 Microsoft Teams 的机器人通道中将消息作为机器人发送给用户 - Sending a message to users as a bot in bot channel of Microsoft Teams using the Graph API MS Teams Graph API 使用 JSON BATCH 请求在频道中发布消息 - MS Teams Graph API using JSON BATCH request to post message in channel 图表 API:Microsoft Teams 频道中应用的 ContentUrl - Graph API: ContentUrl of apps in Microsoft Teams Channel 我的应用程序无法使用图形 API 向 Teams 频道发送消息 - My app is not able to send message to Teams channel using graph api 使用 Microsoft Graph API 或 BOT API 发送 MS Teams 消息 - Sending an MS Teams message using the Microsoft Graph API or BOT API 在 C# 中通过 Microsoft Graph API 在 Microsoft 团队通用频道中发布消息时出现禁止访问错误 - Getting Forbidden error while posting the message in Microsoft teams general channel via Microsoft Graph API in C# MS Graph 团队 api 无法将消息发布到频道并获取频道的消息 - MS Graph teams api cann't post message to channel and get channel's messages 无法使用 Microsoft 图形 API 将应用添加到团队 - Unable to add app to teams using Microsoft graph API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM