-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;
}
}
}
あなたは二回、それをシリアル化している –
ああ、おっと。私はそれを忘れてしまった。 –
出力はどのようになっていますか? –