Example #1
0
        } // end HttpPost

        private string get_user_info(bot ircbot, string uri, string title, string description, string assignee, List <string> labels)
        {
            Issues issue = new Issues {
                title = title, body = description, assignee = assignee, labels = labels.ToArray()
            };

            string         jsonString = issue.ToJSON();
            HttpWebRequest request    = (HttpWebRequest)WebRequest.Create(uri);

            request.Method = "POST";
            request.Headers.Add("Authorization: Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(this.Options["username"] + ":" + this.Options["api"])));
            request.UserAgent = "IRCBot";
            byte[] postBytes = Encoding.ASCII.GetBytes(jsonString);
            // this is important - make sure you specify type this way
            request.ContentLength = postBytes.Length;

            Stream requestStream = request.GetRequestStream();

            requestStream.Write(postBytes, 0, postBytes.Length);
            requestStream.Close();

            string reply = "";

            try
            {
                // grab te response and print it out to the console along with the status code
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                new StreamReader(response.GetResponseStream()).ReadToEnd();
            }
            catch (WebException ex)
            {
                reply = ex.Message;
            }
            return(reply);
        } // end HttpPost
Example #2
0
        private string post_issue(bot ircbot, string uri, string title, string description, string assignee, List<string> labels)
        {
            Issues issue = new Issues { title = title, body = description, assignee = assignee, labels = labels.ToArray() };

            string jsonString = issue.ToJSON();
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
            request.Method = "POST";
            request.Headers.Add("Authorization: Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(this.Options["username"] + ":" + this.Options["api"])));
            request.UserAgent = "IRCBot";
            byte[] postBytes = Encoding.ASCII.GetBytes(jsonString);
            // this is important - make sure you specify type this way
            request.ContentLength = postBytes.Length;

            Stream requestStream = request.GetRequestStream();
            requestStream.Write(postBytes, 0, postBytes.Length);
            requestStream.Close();

            string reply = "";
            try
            {
                // grab te response and print it out to the console along with the status code
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                new StreamReader(response.GetResponseStream()).ReadToEnd();
            }
            catch (WebException ex)
            {
                reply = ex.Message;
            }
            return reply;
        }