项目中需要使用GitHub 的restful API来fork, commit, pull request.
在使用HttpWebRequest来Post请求时设置了正确的Header和Body但是返回403Forbidden错误
解决方案:增加获取身份验证信息
httpRequest.UserAgent = "Code Sample Web Client"
GitHub for API: https://developer.github.com/v3/repos/forks/#create-a-fork
public static async Task PullRequestAsync()
{
string url_fork = @"https://api.github.com/repos/OWNERNAME/REPO_YOU_WANT/forks";
string res = Post(url_fork, "");//如果是organization调用需要加参数
Console.WriteLine(res);
}
public static string Post(string url, string content)
{
string result = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
//req.Headers.Add("Cont