我尝试使用以下方法以Json格式将消息传递给MS Flow,但是一旦传递了任何符号(如“”),由于将符号识别为代码,我将收到错误消息。
public static bool notification(string customer, string comment)
{
try
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create("my msflow link goes here");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{ \"customer\":\"" + customer + "\",\"comment\":\"" + comment + "\"}";
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
return true;
}
catch (Exception)
{
return false;
}
}