Thursday 25 September 2014

How do I use the Redmine REST API over https from .net?

 

  Best way to use Redmine REST API over https from .net?

 

  protected void Page_Load(object sender, EventArgs e)
        {

            string host = ConfigurationManager.AppSettings["redmineHost"].ToString();

            string key = ConfigurationManager.AppSettings["redmineKey"].ToString();           

            //  var manager = new RedmineManager(host, user,pass);
            var manager = new RedmineManager(host,
key);
            string str= ReadIssue(host,
key);
            Response.Write(str);
         }

      

    public string ReadIssue (string host,string key)
    {
       ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, error) => true;

            var request = (HttpWebRequest)WebRequest.Create(host+"/issues/1083.json?key="+key+"");
            request.CookieContainer = new CookieContainer();
            request.Method = "GET";
            request.ContentType = "application/json";
           
            using (var response = request.GetResponse()) // Hangs here
            using (Stream responseStream = response.GetResponseStream())
            {
                StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
                return reader.ReadToEnd();
            }
   
    }

No comments:

Post a Comment

C# LINQ Joins With SQL

There are  Different Types of SQL Joins  which are used to query data from more than one database tables. In this article, you will learn a...