Я создаю программу, используя C#. NET Core 3.1, которая распечатает сообщение на свободный канал, который я создал. Проблема в том, что я не могу получить правильный формат для вставки ($ "{DateTime.Now}: { msg} \ n ") в строке request.addParameter.
текущий код просто печатает" msg "вместо переменной msg
using System;
using LoggerCore;
using RestSharp;
using RestSharp.Authenticators;
namespace SlackChannel
{
public class SlackLogger : BaseLogger
{
protected override void SubClassLog(string msg,LogOutput logOutput)
{
if (logOutput == LogOutput.OutputToAll || logOutput == LogOutput.OutputToSlack)
{
var client = new RestClient("https://hooks.slack.com/services/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");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer xoxp-1016176172148-1005162966131-1005208408259-f08d87bb747a04f66f4daa1846fe7659");
request.AddHeader("Content-Type", "text/plain");
request.AddParameter("text/plain", "{\n\t\"text\": \"msg\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
}
}
}
}