-1
작동하지 않아도 github에서 문제를 만들 수 없습니다. 나는 그럭저럭 무엇인가의 이유로 그것을 다시 돌려받을 수있다.C# Github API 문제를 만들 수 없습니다.
내가하려는 것은 POST와 동일한 기능을 가진 json 형식으로 문자열을 업로드하는 것입니다. 분명히 작동하지 않는 것 같습니다.
using System;
using System.Collections.Generic;
using System.Net;
using Newtonsoft.Json;
namespace TestProject
{
class Program
{
static void Main(string[] args)
{
CreateGithubIssue("Test Issue - C#", "This is just a test to check if i can manage to create an issue from C#.");
}
static string username = "someUser";
static string password = "somePassword";
static string repoIssueLink = "http://api.github.com/repos/someUser/someRepo/issues";
public static void CreateGithubIssue(string Title, string Description)
{
WebClient webClient = new WebClient();
webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
webClient.Credentials = new NetworkCredential(username, password);
string jsonPost = JsonConvert.SerializeObject(new Issue(Title, Description), Formatting.Indented);
string response = webClient.UploadString(repoIssueLink, jsonPost);
Console.WriteLine(response);
Console.WriteLine(jsonPost);
}
}
public class Issue
{
public string title;
public string body;
public List<string> assignees;
public int milestone;
public List<string> labels;
public Issue(string title = "Default Title", string body = "Default Body", List<string> assignees = null, int milestone = 0, List<string> labels = null)
{
if (assignees == null) assignees = new List<string>();
if (labels == null) labels = new List<string>();
this.title = title;
this.body = body;
this.assignees = assignees;
this.milestone = milestone;
this.labels = labels;
}
}
}
당신은 두 번 직렬화하고 –
오. 나는 그것을 잊어 버렸다. –
출력은 어떻게됩니까? –