我有一个从Microsoft团队“自定义”选项卡向聊天窗口发送通知的方案。因此,我试图调用Microsoft Graph API来将消息发送到特定的chatId中:Post https://graph.microsoft.com/beta/chats/${chatId}/messages我可以成功获取access_token,但是在调用post request时将通知发送到chatId时,出现“ 401未经授权”错误。我的代码有什么问题?
var message = {
"body": {
"content": "Hello World"
}
};
fetch(`https://graph.microsoft.com/beta/${context.userObjectId}/chats/${chatId}/messages`, {
method: "POST",
mode: "cors",
cache: "no-cache",
headers: {
'Content-Type': "application/json;charset=utf-8",
'Authorization': `Bearer ${fetched_accessToken}`
},
body: JSON.stringify(message)
}).then((response) => {
alert(response.statusText);
}).catch((err) => {
alert(err);
});
}
此代码有什么问题?
如果您已经有一个Teams应用程序,并且在选项卡上还希望与聊天进行交流,则应考虑创建一个机器人并使用主动消息传递。请参阅https://docs.microsoft.com/zh-CN/microsoftteams/platform/bots/how-to/conversations/send-proactive-messages?tabs=dotnet和https://docs.microsoft.com/en -我们/图/团队主动消息
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句