1

Im fiddling with a project and I want to automate that certain events can automatically make github issue tickets

Followed How to automate add my c# application issues to Github programmatically But I seem to be missing a piece because its stated to make a webhook but in github that means an external page? I think I can get the code working with that example if I understand the prerequisite parts on the github side.

System.Net.WebRequest request = System.Net.WebRequest.Create("https://api.github.com/repos/organisation/reponame/issues ");
String Message = "Testing";
request.Method = "POST";
string postData = "{'title':'test', 'body':'{0}'}";
byte[] byteArray = Encoding.UTF8.GetBytes(string.Format(postData, Message));
request.ContentLength = byteArray.Length;
System.IO.Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
System.Net.WebResponse response = request.GetResponse();

Edited code to look like:

System.Net.WebRequest request = System.Net.WebRequest.Create("https://api.github.com/repos/organization/repo/issues");
            request.Method = "POST";
            string postData = "{'title':'testing', 'body':'testing testing'}";
            byte[] byteArray = Encoding.UTF8.GetBytes(postData);
            request.ContentLength = byteArray.Length;
            System.IO.Stream dataStream = request.GetRequestStream();
            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();
            System.Net.WebResponse response = request.GetResponse();
            Console.WriteLine(response.Headers.Get("url"));

Though that returns 403 (previous had an error which I fixed) and Im guessing this is down to not adding any kind of credentials or auth but I have no idea on how thats done and I cant seem to find a good documentation on this.

Natherul
  • 11
  • 3

0 Answers0