1. JIRA REST API 可以做什么?
The Atlassian REST APIs provide a standard interface for interacting with JIRA and our other applications.
REST APIs provide access to resources (data entities) via URI paths. To use a REST API, your application will make an HTTP request and parse the response. Your methods will be the standard HTTP methods like GET, PUT, POST and DELETE. REST APIs operate over HTTP(s) making it easy to use with any programming language or framework. The input and output format for the JIRA REST APIs is JSON.
我们可以通过REST API去访问收保护的资源,例如增、删、改、查ISSUES 。。。。。
支持标准的HTTP method,例如 GET, PUT, POST , DELETE
所有的API的input 和 output 都是 JSON 格式。
Rest API Reference : https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis
2. JIRA REST API鉴权方式
The REST APIs support basic authentication, cookie-based (session) authentication, and OAuth. See the examples of basic authentication, cookie-based authentication, and OAuth.
JIRA REST API 支持3种鉴权方式:
目前JIRA REST API 只支持OAuth1.0
3. 如何使用OAuth方式鉴权
因为basic authentication 和 cookie-based authentication两种方式比较简单,且不推荐使用,这里我说说推荐使用的OAuth方式如何玩。
- 首先需要到Jira上配置Application link,注册一个新的consumer
- 配置客户端oauth信息
Step1: Create application link
JIRA Administration > System > Applications tab > Application links
Step2: Configuring the client
OAuth Config | value |
---|---|
request token url | JIRA_BASE_URL + “/plugins/servlet/oauth/request-token” |
authorization url | JIRA_BASE_URL + “/plugins/servlet/oauth/authorize”” |
access token url | JIRA_BASE_URL + “/plugins/servlet/oauth/access-token” |
oauth signing type | RSA-SHA1,需要生成key pair,且粘贴public key到oauth配置里面 |
consumer key | Step1里面配置的值 |
4. 使用Java client来获取access token
Java oauth client 是基于John Kristian的源码做了一些改进
1 | /** |
5. 使用REST API创建/修改/查询issue
1 | String accessToken = "access token"; |