通过C#使用JIRA api创建新票证后返回票证ID

时间:2017-08-16 11:06:28

标签: c# jira jira-rest-api

我使用下面的SDK通过C#,

与JIRA互动

https://bitbucket.org/farmas/atlassian.net-sdk/wiki/Home

故障单创建成功,响应显示在提示故障单ID的控制台中,但我找不到将故障单ID加载到变量的方法。

        var settings = new JiraRestClientSettings()
        {
            EnableRequestTrace = true
        };

        var jira = Jira.CreateRestClient("https://testjira.xxxxxxxx.com/", 
        jiraUsername, jiraPWD, settings);

        var issue = jira.CreateIssue("TMS");
        issue.Type = "Service Desk Incident";
        issue.Summary = "Test issue created via API 3";
        issue.Description = "Test issue created via API 3";
        issue["Service Desk Priority"] = "Level 3";

        await issue.SaveChangesAsync();

我需要做的就是在变量中捕获此ID。 在此先感谢:)

Error message in the console when credentials are wrong

1 个答案:

答案 0 :(得分:1)

查看bitbucket中的源代码,可以看出,它返回一个Issue对象

public async Task<Issue> SaveChangesAsync(CancellationToken token = default(CancellationToken))

所以,你所需要的只是:

var jiraIssue = await issue.SaveChangesAsync();

jiraIssue.Key是您新创建的密钥。