I am trying to incorporate a slack notification using a Slack bot app API into my C# application. The code below is working fine but the format used for the attachments
field makes it very difficult to edit and maintain... There must be an easier way to populate that json array?
I've tried multiple ways to write it but I can't get it to work properly other than with this unwieldy syntax.
var data = new NameValueCollection
{
["token"] = "token", // Removed my actual token from here obviously
["channel"] = "channel", // Same with the channel
["as_user"] = "true",
["text"] = "test message 2",
["attachments"] = "[{\"fallback\":\"dummy\", \"text\":\"this is an attachment\", \"color\":\"#F35A00\", \"title\" : \"Title\", \"title_link\": \"http://www.google.com\"}]"
};
var client = new WebClient();
var response = client.UploadValues("https://slack.com/api/chat.postMessage", "POST", data);