我正在尝试在我的桌面应用程序中创建一个自定义方法(使用 C#),向 Microsoft 团队发布消息。但我仍然不知道使用什么样的工具或服务来完成它。有可能实现吗?如果是,如何?
我在 Visual Studio 中找到了一个关于 MS-Teams 的金块。但它不会工作。就像在 Visual Studio 市场一样。我发现的是 https://marketplace.visualstudio.com/items?itemName=ms-vsts.vss-services-teams
但是好像不符合我的要求。
您可以按照 4 个步骤向您的频道发送消息通知:
Incoming Webhook
.Incoming Webhook
如果尚未添加,则安装/添加。
Incoming Webhook
通过提供 webhook 名称来配置。点击创建
curl.exe -H "Content-Type:application/json" -d "{'text':'Servers x is started.'}" https://example.webhook.office.com/webhookb2/4dee1c26-036c-4bd2-af75-eb1abd901d18@3c69a296-d747-4ef3-9cc5-e94ee78db030/IncomingWebhook/87557542b42d8d3b04453c4a606f2b92/b852b3d0-84b6-4d98-a547-ae5f53452235
Run Code Online (Sandbox Code Playgroud)
注意:命令行中的 URL 包含一些伪造的 guid 编号,但您需要将其替换为您从 webhooks 中获取的那个。
您可以在 power shell 中调用此行,也可以将其合并到 c# 中作为这个简单示例或其他编程语言:
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://example.webhook.office.com/webhookb2/4dee1c26-036c-4bd2-af75-eb1abd901d18@3c69a296-d747-4ef3-9cc5-e94ee78db030/IncomingWebhook/87557542b42d8d3b04453c4a606f2b92/b852b3d0-84b6-4d98-a547-ae5f53452235"))
{
request.Content = new StringContent("{'text':'Servers x is started.'}");
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
var response = await httpClient.SendAsync(request);
}
}
Run Code Online (Sandbox Code Playgroud)
现在,当我运行命令或 C# 代码时,我会在该频道中收到一条消息:
如果您需要删除已添加的挂钩,请单击已配置,然后单击配置。并管理 webhook:
并删除
归档时间: |
|
查看次数: |
8093 次 |
最近记录: |