我正在将数据发送到带有 webhook 集成的松弛 channel 。 但是当我包含一个换行符 (\n) 时,我得到了 http 500。当我对换行符进行 url 编码时,我看到了编码值,而不是 slacn 中的真正换行符
string body = "foo"
if(!string.IsNullOrWhiteSpace(feedEntry.Link ))
{
body += " \n <" + feedEntry.Link +">";
}
body = "{\"text\": \"" + body+ "\"}";
using(var client = new HttpClient())
{
var msg = new StringContent(body);
var result = await client.PostAsync(url, msg);
}
最佳答案
使用 \\n
而不是 \n
。然后该字符串将包含 \
后跟 n
,这是有效的 JSON 并将由 JSON 解析器转换为换行符。
关于c# - SlackApi - 缺少换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24809551/