查詢jira數據,若是是前端,能夠按照以下格式直接訪問,獲取數據前端
http://jira.company.com/rest/api/2/search?jql=project = REM AND resolution = Unresolved ORDER BY priority DESC, updated DESC api
標紅的倆段,第一段是公司/組織的jira地址,第二段是查詢參數。async
固然,前提是要設置token。函數
C#鏈接Jira,網上的參考寫的都很亂,基本都是之前棄用的版本方案,本身總結了下url
經過NuGet引用:spa
Atlassian.SDK和Atlassian.SDK.Signed隨意一個都行.net
請求Jira-Issues數據:rest
當前經過Jira.CreateRestClient,也能夠經過new Jira(new ServiceLocator(), new JiraCredentials(username, password), new JiraRestClientSettings().Cache)獲取code
而CreateRestClient方法是封裝此Jira構造函數而後返回實例。blog
1 /// <summary> 2 /// 請求Issues 3 /// </summary> 4 /// <param name="jiraUri">公司/組織的Jira地址,如https://jira.huawei.com</param> 5 /// <param name="jqlText"></param> 6 /// <returns></returns> 7 public static async Task<IPagedQueryResult<Issue>> RequestAsync(string jiraUri,string jqlText) 8 { 9 //以前的版本,Atlassian已經棄用 10 // Jira jira = new Jira(url, "admin", "password"); 11 var jira = Jira.CreateRestClient(jiraUri, "admin", "password"); 12 //GetIssuesFromJqlAsync至關於 $"{jiraUri}/rest/api/2/search?jql={requestText}"; 13 var list = await jira.Issues.GetIssuesFromJqlAsync(jqlText, 100); 14 return list; 15 }
1 private async void RequestJiraData() 2 { 3 var requestText = "project = TestProject AND issuetype = 用戶問題 AND status in (新建, 處理中) ORDER BY Rank ASC"; 4 var jiraCvteCom = "https://jira.huawei.com"; 5 var issues = await JiraConnectionHelper.RequestAsync(jiraCvteCom, requestText); 6 Issues = issues.ToList(); 7 }
注:Atlassian.Net SDK 源碼及官網文檔: https://bitbucket.org/farmas/atlassian.net-sdk/wiki/Home