//Post a message using simple strings public void PostMessage(string text, string username = null, string channel = null) { SlackPayload payload = new SlackPayload() { Channel = channel, Username = username, Text = text }; SendMessage(payload); }
private void SendMessage(SlackPayload payload) { string payloadJson = JsonConvert.SerializeObject(payload); using (WebClient client = new WebClient()) { NameValueCollection data = new NameValueCollection(); data["payload"] = payloadJson; var response = client.UploadValues(_uri, "POST", data); //The response text is usually "ok" string responseText = _encoding.GetString(response); } }