using System; using System.IO; using System.Net; using System.Text; namespace TeamRoomTest { class Program { static void Main(string[] args) { try { // Webhook URL string webHookUrl = "https://teamroom.nate.com/api/webhook/6fc73b8a/MDNieeQGWvEGnqQXO4wugRra"; // Send Message string sendMessage = "테스트입니당~"; ASCIIEncoding encoding = new ASCIIEncoding(); byte[] data = encoding.GetBytes(string.Format("content={0}", System.Web.HttpUtility.UrlEncode(sendMessage))); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(webHookUrl); req.Timeout = 5000; req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.ContentLength = data.Length; Stream dataStream = req.GetRequestStream(); dataStream.Write(data, 0, data.Length); dataStream.Close(); req.GetResponse(); } catch(Exception ex) { Console.WriteLine(ex.ToString()); } } } }
※ Webhook url 은 네이트온의 팀룸을 열면 팀룸메뉴 -> 오픈 API 이용하기 -> 새로 연결하기 또는 편집으로 들어가면 확인 가능하다.