I made a template using Slack block kit builder
I read some data and fill eight parameters
in my C# code I have to use interpolated string and curly braces to supply the parameters {}. I also need to skip the braces by adding them twice.
but this is not recognized as correct json when I make the post message call :
var data = new NameValueCollection();
data["token"] = token;
data["channel"] = channelName;
data["as_user"] = "true";
data["text"] = postedMessage;
data["blocks"]=jsonstring;
var client = new WebClient();
var response = client.UploadValues("https://slack.co/api/chat.postMessage", "POST", data);
string responseInString = Encoding.UTF8.GetString(response);
Console.WriteLine(responseInString);
I understand the correct way is to represent these blocks as classes . I tried to follow the slack attachment representation but the blocks are more complex containing inner objects and not string variables as the attachment class . Appreciate your support to represent the blocks using easy syntax and correct json