아래의 소스 코드는 실제로 잔디 웹훅을 이용한 알림 전송에 대한
예이다
try
{
string json = String.Format("{{\"body\" : \"[{0}]트랜스코딩이 완료 되었습니다.\",\"connectInfo\" : [{{\"title\" : \"[{0}]트랜스코딩완료\",\"description\" : \"[{0}]크랜스코딩이 완료되었습니다.{1}{2}\"}}]}}", result.title, Environment.NewLine, result.url);
if (!String.IsNullOrEmpty(result.jandi_webhook))
{
HttpWebRequest newRequest = WebRequest.Create(result.jandi_webhook) as HttpWebRequest;
newRequest.ContentType = "application/json";
newRequest.Accept = "application/vnd.tosslab.jandi-v2+json";
newRequest.Method = "POST";
if (!String.IsNullOrEmpty(json))
{
using (StreamWriter writer = new StreamWriter(newRequest.GetRequestStream()))
{
writer.Write(json);
}
}
HttpWebResponse response = newRequest.GetResponse() as HttpWebResponse;
string r = string.Empty;
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
r = reader.ReadToEnd();
}
newRequest = null;
response = null;
}
}
catch (Exception ex)
{
}