使用API​​将消息发布到松弛状态

时间:2020-02-05 06:56:08

标签: c# httpclient slack-api

我正尝试使用他们的API向Slack发布一条消息,响应内容为:Waiting for activation

这是我的代码:

static async Task<HttpResponseMessage> PostMessage()
{ 
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "xoxb-924542226483-938230541718-gk3vTmwEtOOK01NqO5kW6e0R");
    var atttrJson = new stackAttributes { channel = "#cymulateinterview", text = "Good Morning all" };
    var json = new JavaScriptSerializer().Serialize(atttrJson);
    var buffer = System.Text.Encoding.UTF8.GetBytes(json);
    var byteContent = new ByteArrayContent(buffer);
    byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
    var result = await client.PostAsync("https://slack.com/api/chat.postMessage", byteContent);
    return result;
}

我想念什么

0 个答案:

没有答案