Beh*_*zad 9 c# exception github errorcontrolsystem
如何使用C#以编程方式在我的Github存储库中添加问题?
我有一个错误处理程序库(ErrorControlSystem)将它附加到win应用程序中以在SQL表上引发异常.
现在,我希望ErrorControlSystem在自我Github存储库问题上存储自我异常,而不存在目标应用程序异常.
我该怎么办?
Ole*_*ers 13
您可以使用GitHub API.创建webhook并按以下方式添加问题:
POST /repos/:owner/:repo/issues
Run Code Online (Sandbox Code Playgroud)
来自https://developer.github.com/v3/issues/的示例
{
"title": "Found a bug",
"body": "I'm having a problem with this.",
"assignee": "octocat",
"milestone": 1,
"labels": [
"Label1",
"Label2"
]
}
Run Code Online (Sandbox Code Playgroud)
因此,您所要做的就是使用HTTP-POST命令添加问题.
您可以使用WebRequest执行发布请求.
完整描述api:https: //api.github.com/repos/octocat/Hello-World/issues/1347
完成C# - 示例:
public void CreateBug(Exception ex) {
WebRequest request = WebRequest.Create ("https://api.github.com/repos/yourUserName/YourRepo/issues ");
request.Method = "POST";
string postData = "{'title':'exception occured!', 'body':'{0}','assignee': 'yourUserName'}";
byte[] byteArray = Encoding.UTF8.GetBytes (string.Format(postData,ex));
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream ();
dataStream.Write (byteArray, 0, byteArray.Length);
dataStream.Close ();
WebResponse response = request.GetResponse ();
}
Run Code Online (Sandbox Code Playgroud)
现在您的问题已经创建,响应包含来自GitHub的响应
这是"快速,简单"的解决方案.如果你想对GitHub问题做更多的事情,@ VonC的答案可能会更好,因为它提供了更多与对象相关的解决方案
Von*_*onC 12
如果需要使用C#以编程方式在GitHub存储库上创建问题,可以参考octokit/octokit.net将使用GitHub API 的C#项目.
它可以创建问题:
var createIssue = new NewIssue("this thing doesn't work");
var issue = await _issuesClient.Create("octokit", "octokit.net", createIssue);
Run Code Online (Sandbox Code Playgroud)
Create返回Task<Issue>表示已创建问题的a.
| 归档时间: |
|
| 查看次数: |
1391 次 |
| 最近记录: |