В основном я хочу разместить локальные файлы изображений в Slack.Метод принимает только параметры URL, но я хочу передать путь к файлу.Есть ли способ добиться этого с помощью форматированного сообщения?У меня был пример с этого сайта, кстати:
public class SlackAttachment
{
public string fallback { get; set; }
...
public string author_name { get; set; }
public string image_url { get; set; }
}
public static void SendMessageToSlack()
{
string token= "myTokenHere";
var sampleAttachment = new SlackAttachment[]
{
new SlackAttachment {
fallback = "this did not work",
text = "text here",
color = "0b7c1e",
pretext = "",
author_name = "myName",
author_icon = @"https://i.imgur.com/02sddfQMt9p.png",
author_link = "",
title = "no title",
title_link = "Title link here",
//image_url = @"https://i.imgur.com/U9S0CDG.png",
// cannot replace this with
// C:\Users\Public\image.png
thumb_url = @"",
footer = "footer here",
footer_icon = migrationIcon
},
};
var attachmentsJson = JsonConvert.SerializeObject(sampleAttachment);
var data = new NameValueCollection();
data["token"] = token;
data["channel"] = channelName;
data["as_user"] = "true";
data["text"] = "";
data["attachments"] = attachmentsJson;
var client = new WebClient();
var response = client.UploadValues("https://slack.com/api/chat.postMessage", "POST", data);
string responseInString = Encoding.UTF8.GetString(response);
Console.WriteLine(responseInString);
}