[英]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.