JIRA REST API 实例
创建Issue
获取创建Issue所需的元数据 createmeta
创建一个Issue,需要知道创建一个issue所知道的必要的数据,比如 project key ,每个project下允许的issue type , issue有哪些字段,哪些必填字段。这些必要的元数据信息都可以通过 createmeta 来获得,
下面具体说一下如何获取这些信息
1. project 和 project type 信息
我们这里假设project key 的值很容易获取到,因为你可以通project信息以及issue url的前缀很容易获取project key ,通过 createmeta也可以获取project的列表
如果你想要创建一个issue, 但不知道 issue type的值是是什么(这个通常不容易获取到,尤其有中文翻译的情况下),首先使用issue 的 createmeta 信息可以获取
这个 API 是 GET /rest/api/2/issue/createmeta , 有四个参数 projectIds,projectKeys,issuetypeIds, issuetypeNames 和 一个 expand
比如我们想知道 project MAC 能有哪些 issureType可以用, 就可以刻使用这个 API
http://jira.teamsinspace.com:8080/rest/api/latest/issue/createmeta?projectKeys=MAC
curl 的命令为
curl -X GET \
'http://jira.teamsinspace.com:8080/rest/api/latest/issue/createmeta?projectKeys=MAC' \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n'
返回的响应如下
{
"expand": "projects",
"projects": [
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/project/11000",
"id": "11000",
"key": "MAC",
"name": "Marketing Creatives",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/projectavatar?pid=11000&avatarId=10806",
"24x24": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=small&pid=11000&avatarId=10806",
"16x16": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=xsmall&pid=11000&avatarId=10806",
"32x32": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=medium&pid=11000&avatarId=10806"
},
"issuetypes": [
{
"self": "http://jira.teamsinspace.com:8080/rest/api/latest/issuetype/3",
"id": "3",
"description": "A task that needs to be done.",
"iconUrl": "http://jira.teamsinspace.com:8080/secure/viewavatar?size=xsmall&avatarId=10618&avatarType=issuetype",
"name": "Task",
"subtask": false
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/latest/issuetype/5",
"id": "5",
"description": "The sub-task of the issue",
"iconUrl": "http://jira.teamsinspace.com:8080/secure/viewavatar?size=xsmall&avatarId=10616&avatarType=issuetype",
"name": "Sub-task",
"subtask": true
}
]
}
]
}
issuetype 的 id 和 name 都可以获得,这些都是创建issue需要的
2. issue 的字段信息
有了issuetype的信息了,现在我们想知道创建Task这个issue都有哪些字段, 这时候expland 就用上了, 在上面的URL基础上再加上 expand=projects.issuetypes.fields 就可以了
至于为什么expand是projects.issuetypes.fields , 我们可以看到上面那个请求的返回结果是有 "expand": "projects" ,从issue的返回数据中可以看到 json的层级结构就是 porjects -> issuetype -> fields
于是,http请求构造如下
curl -X GET \
'http://jira.teamsinspace.com:8080/rest/api/latest/issue/createmeta?projectKeys=MAC&issuetypeNames=Task&expand=projects.issuetypes.fields' \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n'
返回结果为:
{
"expand": "projects",
"projects": [
{
"expand": "issuetypes",
"self": "http://jira.teamsinspace.com:8080/rest/api/2/project/11000",
"id": "11000",
"key": "MAC",
"name": "Marketing Creatives",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/projectavatar?pid=11000&avatarId=10806",
"24x24": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=small&pid=11000&avatarId=10806",
"16x16": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=xsmall&pid=11000&avatarId=10806",
"32x32": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=medium&pid=11000&avatarId=10806"
},
"issuetypes": [
{
"self": "http://jira.teamsinspace.com:8080/rest/api/latest/issuetype/3",
"id": "3",
"description": "A task that needs to be done.",
"iconUrl": "http://jira.teamsinspace.com:8080/secure/viewavatar?size=xsmall&avatarId=10618&avatarType=issuetype",
"name": "Task",
"subtask": false,
"expand": "fields",
"fields": {
"customfield_11215": {
"required": false,
"schema": {
"type": "string",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:textarea",
"customId": 11215
},
"name": "Root cause",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"summary": {
"required": true,
"schema": {
"type": "string",
"system": "summary"
},
"name": "Summary",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"issuetype": {
"required": true,
"schema": {
"type": "issuetype",
"system": "issuetype"
},
"name": "Issue Type",
"hasDefaultValue": false,
"operations": [],
"allowedValues": [
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issuetype/3",
"id": "3",
"description": "A task that needs to be done.",
"iconUrl": "http://jira.teamsinspace.com:8080/secure/viewavatar?size=xsmall&avatarId=10618&avatarType=issuetype",
"name": "Task",
"subtask": false,
"avatarId": 10618
}
]
},
"attachment": {
"required": false,
"schema": {
"type": "array",
"items": "attachment",
"system": "attachment"
},
"name": "Attachment",
"hasDefaultValue": false,
"operations": []
},
"duedate": {
"required": false,
"schema": {
"type": "date",
"system": "duedate"
},
"name": "Due Date",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"description": {
"required": false,
"schema": {
"type": "string",
"system": "description"
},
"name": "Description",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"project": {
"required": true,
"schema": {
"type": "project",
"system": "project"
},
"name": "Project",
"hasDefaultValue": false,
"operations": [
"set"
],
"allowedValues": [
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/project/11000",
"id": "11000",
"key": "MAC",
"name": "Marketing Creatives",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/projectavatar?pid=11000&avatarId=10806",
"24x24": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=small&pid=11000&avatarId=10806",
"16x16": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=xsmall&pid=11000&avatarId=10806",
"32x32": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=medium&pid=11000&avatarId=10806"
}
}
]
},
"reporter": {
"required": true,
"schema": {
"type": "user",
"system": "reporter"
},
"name": "Reporter",
"autoCompleteUrl": "http://jira.teamsinspace.com:8080/rest/api/latest/user/search?username=",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"assignee": {
"required": false,
"schema": {
"type": "user",
"system": "assignee"
},
"name": "Assignee",
"autoCompleteUrl": "http://jira.teamsinspace.com:8080/rest/api/latest/user/assignable/search?issueKey=null&username=",
"hasDefaultValue": false,
"operations": [
"set"
]
},
"priority": {
"required": false,
"schema": {
"type": "priority",
"system": "priority"
},
"name": "Priority",
"hasDefaultValue": true,
"operations": [
"set"
],
"allowedValues": [
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/1",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/blocker.svg",
"name": "Blocker",
"id": "1"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/10000",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/critical.svg",
"name": "Highest",
"id": "10000"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/10001",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/major.svg",
"name": "High",
"id": "10001"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/2",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/critical.svg",
"name": "Critical",
"id": "2"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/3",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/major.svg",
"name": "Major",
"id": "3"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/10002",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/trivial.svg",
"name": "Medium",
"id": "10002"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/5",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/trivial.svg",
"name": "Trivial",
"id": "5"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/4",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/minor.svg",
"name": "Minor",
"id": "4"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/10003",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/minor.svg",
"name": "Low",
"id": "10003"
}
]
},
"timetracking": {
"required": false,
"schema": {
"type": "timetracking",
"system": "timetracking"
},
"name": "Time Tracking",
"hasDefaultValue": false,
"operations": [
"set",
"edit"
]
},
"labels": {
"required": false,
"schema": {
"type": "array",
"items": "string",
"system": "labels"
},
"name": "Labels",
"autoCompleteUrl": "http://jira.teamsinspace.com:8080/rest/api/1.0/labels/suggest?query=",
"hasDefaultValue": false,
"operations": [
"add",
"set",
"remove"
]
}
}
}
]
}
]
}
创建Issue
下面我们创建一个issue
project 为 MAC ,
issueType: Task
加上标题和描述
设置到期时间为 2018年8月8日
设置某个自定义字段内容为 "from API " , 通过 POST 请求来创建issue
curl -X POST \
http://jira.teamsinspace.com:8080/rest/api/latest/issue/ \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
-H 'Content-Type: application/json' \
-d '{
"fields": {
"project":
{
"key": "MAC"
},
"summary": "No REST for the Wicked.",
"description": "Creating of an issue using key for projects and issue types using the REST API",
"issuetype": {
"name": "Task"
},
"duedate" : "2018-08-08",
"customfield_11215" : " from API"
}
}'
返回结果 201 Created
{
"id": "15622",
"key": "MAC-19",
"self": "http://jira.teamsinspace.com:8080/rest/api/latest/issue/15622"
}
返回创建成功能的issue id, key 以及api链接
创建subtask
从createmeta 中可以看到subtask的issuetype, 而且 parent 必须的
和创建issue类似,只是增加了parent, 下面是一个例子
curl -X POST \
http://jira.teamsinspace.com:8080/rest/api/latest/issue/ \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 998808c6-4dc1-4a51-a078-70f1159010b9' \
-d '{
"fields":
{
"project":
{
"key": "MAC"
},
"parent":
{
"key": "MAC-16"
},
"summary": "Sub-task of MAC-16",
"description": "Don'\''t forget to do this too.",
"issuetype":
{
"id": "5"
}
}
}'
返回结果为 201 Created
{
"id": "15622",
"key": "MAC-19",
"self": "http://jira.teamsinspace.com:8080/rest/api/latest/issue/15622"
}
编辑Issue
获取编辑Issue所需的元数据 editmeta
获取editmeta使用这个API , 这里需要指定某一个issue,如下的例子 MAC-16
http://jira.teamsinspace.com:8080/rest/api/latest/issue/MAC-16/editmeta
curl命令为
curl -X GET \
http://jira.teamsinspace.com:8080/rest/api/latest/issue/MAC-16/editmeta \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
返回结果为 200 OK , 显示了哪些字段可以修改
{
"fields": {
"summary": {
"required": true,
"schema": {
"type": "string",
"system": "summary"
},
"name": "Summary",
"operations": [
"set"
]
},
"issuetype": {
"required": true,
"schema": {
"type": "issuetype",
"system": "issuetype"
},
"name": "Issue Type",
"operations": [],
"allowedValues": [
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issuetype/3",
"id": "3",
"description": "A task that needs to be done.",
"iconUrl": "http://jira.teamsinspace.com:8080/secure/viewavatar?size=xsmall&avatarId=10618&avatarType=issuetype",
"name": "Task",
"subtask": false,
"avatarId": 10618
}
]
},
"components": {
"required": false,
"schema": {
"type": "array",
"items": "component",
"system": "components"
},
"name": "Component/s",
"operations": [
"add",
"set",
"remove"
],
"allowedValues": []
},
"description": {
"required": false,
"schema": {
"type": "string",
"system": "description"
},
"name": "Description",
"operations": [
"set"
]
},
"reporter": {
"required": true,
"schema": {
"type": "user",
"system": "reporter"
},
"name": "Reporter",
"autoCompleteUrl": "http://jira.teamsinspace.com:8080/rest/api/latest/user/search?username=",
"operations": [
"set"
]
},
"priority": {
"required": false,
"schema": {
"type": "priority",
"system": "priority"
},
"name": "Priority",
"operations": [
"set"
],
"allowedValues": [
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/1",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/blocker.svg",
"name": "Blocker",
"id": "1"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/10000",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/critical.svg",
"name": "Highest",
"id": "10000"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/10001",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/major.svg",
"name": "High",
"id": "10001"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/2",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/critical.svg",
"name": "Critical",
"id": "2"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/3",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/major.svg",
"name": "Major",
"id": "3"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/10002",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/trivial.svg",
"name": "Medium",
"id": "10002"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/5",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/trivial.svg",
"name": "Trivial",
"id": "5"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/4",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/minor.svg",
"name": "Minor",
"id": "4"
},
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/10003",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/minor.svg",
"name": "Low",
"id": "10003"
}
]
},
"timetracking": {
"required": false,
"schema": {
"type": "timetracking",
"system": "timetracking"
},
"name": "Time Tracking",
"operations": [
"set",
"edit"
]
},
"labels": {
"required": false,
"schema": {
"type": "array",
"items": "string",
"system": "labels"
},
"name": "Labels",
"autoCompleteUrl": "http://jira.teamsinspace.com:8080/rest/api/1.0/labels/suggest?query=",
"operations": [
"add",
"set",
"remove"
]
},
"customfield_11215": {
"required": false,
"schema": {
"type": "string",
"custom": "com.atlassian.jira.plugin.system.customfieldtypes:textarea",
"customId": 11215
},
"name": "Root cause",
"operations": [
"set"
]
},
"attachment": {
"required": false,
"schema": {
"type": "array",
"items": "attachment",
"system": "attachment"
},
"name": "Attachment",
"operations": []
},
"duedate": {
"required": false,
"schema": {
"type": "date",
"system": "duedate"
},
"name": "Due Date",
"operations": [
"set"
]
},
"comment": {
"required": false,
"schema": {
"type": "comments-page",
"system": "comment"
},
"name": "Comment",
"operations": [
"add",
"edit",
"remove"
]
},
"assignee": {
"required": false,
"schema": {
"type": "user",
"system": "assignee"
},
"name": "Assignee",
"autoCompleteUrl": "http://jira.teamsinspace.com:8080/rest/api/latest/user/assignable/search?issueKey=MAC-16&username=",
"operations": [
"set"
]
}
}
}
这里有一个 operations , 有 set add edit remove 的操作, 标明这个字段可以允许什么操作, 如
"comment": {
"required": false,
"schema": {
"type": "comments-page",
"system": "comment"
},
"name": "Comment",
"operations": [
"add",
"edit",
"remove"
]
}
表明可以对于comment ,通过issue的编辑可以有 add, edit 和remove的操作
编辑issue的方式
编辑Issue通过 PUT /rest/api/2/issue/{issueIdOrKey} API 来完成
有两种方式
- 使用 field 指定 "field_id": field_value 来直接编辑某个字段的值
- 使用包含在 update 的operations 操作 ( 如 set )来更新
实际上 field 是 update set 的一种快捷的表达方式
operation 操作要包含在列表中,用[] 括起来
如果设置成功会返回 204 No Content
分配assignee
这里我们使用 filed 的方式来直接指定
将issue MAC-18 分配给 agrant
请求消息
curl -X PUT \
http://jira.teamsinspace.com:8080/rest/api/latest/issue/MAC-18 \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
-H 'Content-Type: application/json' \
-d '{
"fields": {
"assignee":{"name":"agrant"}
}
}'
返回结果
204 No Content
设置多个字段
这里我们使用update set 的方式
将issue MAC-18 分配给 agrant, 并将字段 customfield_11215 设置为"hello"
operation 操作要包含在列表中,用[] 括起来
请求消息
curl -X PUT \
http://jira.teamsinspace.com:8080/rest/api/latest/issue/MAC-18 \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
-H 'Content-Type: application/json' \
-d '{
"update" : {
"assignee" : [{"set" : {"name" : "agrant"}}],
"customfield_11215" : [{"set" : "hello"}]
}
}'
返回结果
204 No Content
增加Comment
comment设置的方式
操作comment有两种方式
- 通过comment 资源, 即在url中加上/comment 就可以编辑comment内容, 使用 POST 方法
- 通过编辑issue也可以添加comment, 使用 PUT 方法
通过comment资源添加comment
调用的API
POST http://jira.teamsinspace.com:8080/rest/api/latest/issue/MAC-18/comment
请求消息
curl -X POST \
http://jira.teamsinspace.com:8080/rest/api/latest/issue/MAC-18/comment \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
-H 'Content-Type: application/json' \
-d '{
"body": "This is a comment generated by api."
}'
返回结果
200 OK
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issue/15621/comment/18617",
"id": "18617",
"author": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "tisadmin@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=admin&avatarId=10500",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=admin&avatarId=10500",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=admin&avatarId=10500",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=admin&avatarId=10500"
},
"displayName": "Admin Istrator",
"active": true,
"timeZone": "Asia/Hong_Kong"
},
"body": "This is a comment from api.",
"updateAuthor": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "tisadmin@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=admin&avatarId=10500",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=admin&avatarId=10500",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=admin&avatarId=10500",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=admin&avatarId=10500"
},
"displayName": "Admin Istrator",
"active": true,
"timeZone": "Asia/Hong_Kong"
},
"created": "2018-06-06T02:23:08.920+0000",
"updated": "2018-06-06T02:23:08.920+0000"
}
通过编辑issue来添加comment
调用的API
PUT http://jira.teamsinspace.com:8080/rest/api/latest/issue/MAC-18
请求消息
curl -X PUT \
http://jira.teamsinspace.com:8080/rest/api/latest/issue/MAC-18 \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
-H 'Content-Type: application/json' \
-d '{
"update": {
"comment": [
{
"add": {
"body": "add a comment by edit issue via api"
}
}
]
}
}'
返回结果
204 No Content
我们注意到,通过编辑issue来添加comment的相应消只有一个204 No Content ,没有填下的comment的信息返回;而通过comment资源添加的comment 会返回一个body, 里面记录了增加comment的详细内容
搜索issue
搜索issue的方式
通过API http://jira.teamsinspace.com:8080/rest/api/latest/search 来实现,有两种方式
- 将JQL查询条件写到 GET请求的参数中
- 将JQL查询条件写到POST请求的body中
POST 可以将 JQL 放入到body中,能做复杂的查询
search有几个参数
参数 | 类型 | 描述 |
---|---|---|
jql | string | JQL内容 |
startAt | int | 搜索返回结果的起始位置 |
maxResults | int | 返回结果的数量 |
validateQuery | boolean | 是否是JQL,默认是 true |
fields | string | 返回的字段 |
使用GET + 参数 来搜索
搜索 assignee是agrant, 返回前3个结果
请求消息
curl -X GET \
'http://jira.teamsinspace.com:8080/rest/api/latest/search?jql=assignee=agrant%20&startAt=1&maxResults=2' \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
返回结果
200 OK
{
"expand": "schema,names",
"startAt": 1,
"maxResults": 2,
"total": 29,
"issues": [
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "14012",
"self": "http://jira.teamsinspace.com:8080/rest/api/latest/issue/14012",
"key": "TIS-125",
"fields": {
"issuetype": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issuetype/6",
"id": "6",
"description": "Created by JIRA Software - do not edit or delete. Issue type for a big user story that needs to be broken down.",
"iconUrl": "http://jira.teamsinspace.com:8080/secure/viewavatar?size=xsmall&avatarId=10607&avatarType=issuetype",
"name": "Epic",
"subtask": false,
"avatarId": 10607
},
"timespent": null,
"project": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/project/10001",
"id": "10001",
"key": "TIS",
"name": "Teams in Space",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/projectavatar?pid=10001&avatarId=10400",
"24x24": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=small&pid=10001&avatarId=10400",
"16x16": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=xsmall&pid=10001&avatarId=10400",
"32x32": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=medium&pid=10001&avatarId=10400"
}
},
"fixVersions": [],
"customfield_11001": null,
"customfield_11200": null,
"aggregatetimespent": null,
"resolution": null,
"customfield_11201": null,
"customfield_11202": null,
"customfield_11401": null,
"customfield_11203": null,
"customfield_11400": null,
"customfield_10501": null,
"customfield_10503": null,
"customfield_10900": null,
"customfield_10506": null,
"resolutiondate": null,
"workratio": -1,
"lastViewed": null,
"watches": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issue/TIS-125/watchers",
"watchCount": 1,
"isWatching": true
},
"created": "2018-05-11T00:49:21.000+0000",
"priority": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/3",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/major.svg",
"name": "Major",
"id": "3"
},
"labels": [],
"customfield_10301": null,
"customfield_10016": null,
"customfield_11502": null,
"customfield_10017": null,
"customfield_11501": null,
"customfield_10018": null,
"customfield_11504": null,
"customfield_10019": null,
"customfield_11503": null,
"timeestimate": null,
"aggregatetimeoriginalestimate": null,
"versions": [],
"issuelinks": [
{
"id": "10406",
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issueLink/10406",
"type": {
"id": "10003",
"name": "Relates",
"inward": "relates to",
"outward": "relates to",
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issueLinkType/10003"
},
"outwardIssue": {
"id": "14011",
"key": "TIS-124",
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issue/14011",
"fields": {
"summary": "Planet Taxi",
"status": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/status/1",
"description": "The issue is open and ready for the assignee to start work on it.",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/statuses/generic.png",
"name": "Open",
"id": "1",
"statusCategory": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/statuscategory/2",
"id": 2,
"key": "new",
"colorName": "blue-gray",
"name": "To Do"
}
},
"priority": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/3",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/major.svg",
"name": "Major",
"id": "3"
},
"issuetype": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issuetype/10000",
"id": "10000",
"description": "",
"iconUrl": "http://jira.teamsinspace.com:8080/secure/viewavatar?size=xsmall&avatarId=10600&avatarType=issuetype",
"name": "Initiative",
"subtask": false,
"avatarId": 10600
}
}
}
}
],
"assignee": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=agrant",
"name": "agrant",
"key": "agrant",
"emailAddress": "agrant@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=agrant&avatarId=10501",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=agrant&avatarId=10501",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=agrant&avatarId=10501",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=agrant&avatarId=10501"
},
"displayName": "Alana Grant",
"active": true,
"timeZone": "Asia/Shanghai"
},
"updated": "2018-05-11T00:49:22.000+0000",
"status": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/status/1",
"description": "The issue is open and ready for the assignee to start work on it.",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/statuses/generic.png",
"name": "Open",
"id": "1",
"statusCategory": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/statuscategory/2",
"id": 2,
"key": "new",
"colorName": "blue-gray",
"name": "To Do"
}
},
"components": [],
"timeoriginalestimate": null,
"description": null,
"customfield_10010": null,
"customfield_10011": null,
"customfield_11100": null,
"customfield_10012": "9223372036854775807",
"customfield_10013": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/customFieldOption/10000",
"value": "To Do",
"id": "10000"
},
"customfield_10014": "Planet Taxi Device exploration & research",
"customfield_10015": "ghx-label-4",
"customfield_11215": null,
"customfield_10600": "0|1005xc:",
"customfield_11216": null,
"customfield_11219": null,
"aggregatetimeestimate": null,
"summary": "Planet Taxi Device exploration & research",
"creator": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "tisadmin@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=admin&avatarId=10500",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=admin&avatarId=10500",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=admin&avatarId=10500",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=admin&avatarId=10500"
},
"displayName": "Admin Istrator",
"active": true,
"timeZone": "Asia/Hong_Kong"
},
"subtasks": [],
"reporter": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "tisadmin@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=admin&avatarId=10500",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=admin&avatarId=10500",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=admin&avatarId=10500",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=admin&avatarId=10500"
},
"displayName": "Admin Istrator",
"active": true,
"timeZone": "Asia/Hong_Kong"
},
"customfield_11210": null,
"aggregateprogress": {
"progress": 0,
"total": 0
},
"customfield_11211": null,
"customfield_11212": null,
"customfield_11213": null,
"customfield_11214": null,
"customfield_11204": null,
"customfield_11205": null,
"customfield_11402": null,
"environment": null,
"customfield_11206": null,
"customfield_11207": null,
"customfield_11208": null,
"customfield_11209": null,
"duedate": null,
"progress": {
"progress": 0,
"total": 0
},
"votes": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issue/TIS-125/votes",
"votes": 0,
"hasVoted": false
}
}
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "14011",
"self": "http://jira.teamsinspace.com:8080/rest/api/latest/issue/14011",
"key": "TIS-124",
"fields": {
"issuetype": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issuetype/10000",
"id": "10000",
"description": "",
"iconUrl": "http://jira.teamsinspace.com:8080/secure/viewavatar?size=xsmall&avatarId=10600&avatarType=issuetype",
"name": "Initiative",
"subtask": false,
"avatarId": 10600
},
"timespent": null,
"project": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/project/10001",
"id": "10001",
"key": "TIS",
"name": "Teams in Space",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/projectavatar?pid=10001&avatarId=10400",
"24x24": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=small&pid=10001&avatarId=10400",
"16x16": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=xsmall&pid=10001&avatarId=10400",
"32x32": "http://jira.teamsinspace.com:8080/secure/projectavatar?size=medium&pid=10001&avatarId=10400"
}
},
"fixVersions": [],
"customfield_11001": null,
"customfield_11200": null,
"aggregatetimespent": null,
"resolution": null,
"customfield_11201": null,
"customfield_11202": null,
"customfield_11401": null,
"customfield_11203": null,
"customfield_11400": null,
"customfield_10501": null,
"customfield_10503": null,
"customfield_10900": null,
"customfield_10506": null,
"resolutiondate": null,
"workratio": -1,
"lastViewed": null,
"watches": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issue/TIS-124/watchers",
"watchCount": 1,
"isWatching": true
},
"created": "2018-05-11T00:49:20.000+0000",
"priority": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/3",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/major.svg",
"name": "Major",
"id": "3"
},
"labels": [],
"customfield_10301": null,
"customfield_10016": null,
"customfield_11502": null,
"customfield_10017": null,
"customfield_11501": null,
"customfield_10018": 20,
"customfield_11504": null,
"customfield_11503": null,
"timeestimate": null,
"aggregatetimeoriginalestimate": null,
"versions": [],
"issuelinks": [
{
"id": "10406",
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issueLink/10406",
"type": {
"id": "10003",
"name": "Relates",
"inward": "relates to",
"outward": "relates to",
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issueLinkType/10003"
},
"inwardIssue": {
"id": "14012",
"key": "TIS-125",
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issue/14012",
"fields": {
"summary": "Planet Taxi Device exploration & research",
"status": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/status/1",
"description": "The issue is open and ready for the assignee to start work on it.",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/statuses/generic.png",
"name": "Open",
"id": "1",
"statusCategory": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/statuscategory/2",
"id": 2,
"key": "new",
"colorName": "blue-gray",
"name": "To Do"
}
},
"priority": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/priority/3",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/priorities/major.svg",
"name": "Major",
"id": "3"
},
"issuetype": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issuetype/6",
"id": "6",
"description": "Created by JIRA Software - do not edit or delete. Issue type for a big user story that needs to be broken down.",
"iconUrl": "http://jira.teamsinspace.com:8080/secure/viewavatar?size=xsmall&avatarId=10607&avatarType=issuetype",
"name": "Epic",
"subtask": false,
"avatarId": 10607
}
}
}
}
],
"assignee": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=agrant",
"name": "agrant",
"key": "agrant",
"emailAddress": "agrant@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=agrant&avatarId=10501",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=agrant&avatarId=10501",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=agrant&avatarId=10501",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=agrant&avatarId=10501"
},
"displayName": "Alana Grant",
"active": true,
"timeZone": "Asia/Shanghai"
},
"updated": "2018-05-13T16:53:37.000+0000",
"status": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/status/1",
"description": "The issue is open and ready for the assignee to start work on it.",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/statuses/generic.png",
"name": "Open",
"id": "1",
"statusCategory": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/statuscategory/2",
"id": 2,
"key": "new",
"colorName": "blue-gray",
"name": "To Do"
}
},
"components": [],
"timeoriginalestimate": null,
"description": null,
"customfield_10010": null,
"customfield_10011": null,
"customfield_11100": null,
"customfield_10012": "9223372036854775807",
"customfield_11215": null,
"customfield_10600": "0|10073i:",
"customfield_11216": null,
"customfield_11219": null,
"aggregatetimeestimate": null,
"summary": "Planet Taxi",
"creator": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "tisadmin@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=admin&avatarId=10500",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=admin&avatarId=10500",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=admin&avatarId=10500",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=admin&avatarId=10500"
},
"displayName": "Admin Istrator",
"active": true,
"timeZone": "Asia/Hong_Kong"
},
"subtasks": [],
"reporter": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "tisadmin@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=admin&avatarId=10500",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=admin&avatarId=10500",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=admin&avatarId=10500",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=admin&avatarId=10500"
},
"displayName": "Admin Istrator",
"active": true,
"timeZone": "Asia/Hong_Kong"
},
"customfield_11210": null,
"aggregateprogress": {
"progress": 0,
"total": 0
},
"customfield_11211": null,
"customfield_11212": null,
"customfield_11213": null,
"customfield_11214": null,
"customfield_11204": null,
"customfield_11205": null,
"customfield_11402": null,
"environment": null,
"customfield_11206": null,
"customfield_11207": null,
"customfield_11208": null,
"customfield_11209": null,
"duedate": null,
"progress": {
"progress": 0,
"total": 0
},
"votes": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issue/TIS-124/votes",
"votes": 0,
"hasVoted": false
}
}
}
]
}
使用POST + body 来搜索
下面来实现如下查询
搜索条件:assignee=agrant AND status !=closed ORDER BY updated
起始位置:0
返回数量:2
只返回 "id","key","summary","status" 这几个字段
POST body中的数据内容
{
"jql":"assignee=agrant AND status !=closed ORDER BY updated ",
"startAt":0,
"maxResults":2,
"fields":["id","key","summary","status"]
}
完整的POST请求
curl -X POST \
http://jira.teamsinspace.com:8080/rest/api/latest/search \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/json' \
-H 'Postman-Token: 7dc1428f-6ac4-4b03-bc26-9188922bcc9f' \
-d '{
"jql":"assignee=agrant AND status !=closed ORDER BY updated ",
"startAt":0,
"maxResults":2,
"fields":["id","key","summary","status"]
}'
返回结果
200 OK
{
"expand": "schema,names",
"startAt": 0,
"maxResults": 2,
"total": 20,
"issues": [
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "15621",
"self": "http://jira.teamsinspace.com:8080/rest/api/latest/issue/15621",
"key": "MAC-18",
"fields": {
"summary": "No REST for the Wicked.",
"status": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/status/1",
"description": "The issue is open and ready for the assignee to start work on it.",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/statuses/generic.png",
"name": "Open",
"id": "1",
"statusCategory": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/statuscategory/2",
"id": 2,
"key": "new",
"colorName": "blue-gray",
"name": "To Do"
}
}
}
},
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "14003",
"self": "http://jira.teamsinspace.com:8080/rest/api/latest/issue/14003",
"key": "TIS-116",
"fields": {
"summary": "Go To Mars",
"status": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/status/3",
"description": "This issue is being actively worked on at the moment by the assignee.",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/statuses/inprogress.png",
"name": "Draft",
"id": "3",
"statusCategory": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
}
}
}
]
}
更改issue的状态
获取issue transition
通过 GET http://jira.teamsinspace.com:8080/rest/api/latest/issue/ADR-21/transitions?expand=transitions.fields 可以获取这个issue可以执行哪些transition
GET请求
curl -X GET \
'http://jira.teamsinspace.com:8080/rest/api/latest/issue/ADR-21/transitions?expand=transitions.fields' \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
返回结果
200 OK
{
"expand": "transitions",
"transitions": [
{
"id": "11",
"name": "To Do",
"to": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/status/10210",
"description": "",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/status_generic.gif",
"name": "To Do",
"id": "10210",
"statusCategory": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/statuscategory/2",
"id": 2,
"key": "new",
"colorName": "blue-gray",
"name": "To Do"
}
},
"fields": {}
},
{
"id": "21",
"name": "In Progress",
"to": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/status/10410",
"description": "",
"iconUrl": "http://jira.teamsinspace.com:8080/",
"name": "In Progress",
"id": "10410",
"statusCategory": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
},
"fields": {}
},
{
"id": "31",
"name": "Done",
"to": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/status/10012",
"description": "",
"iconUrl": "http://jira.teamsinspace.com:8080/images/icons/status_generic.gif",
"name": "DONE",
"id": "10012",
"statusCategory": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/statuscategory/3",
"id": 3,
"key": "done",
"colorName": "green",
"name": "Done"
}
},
"fields": {}
}
]
}
更改issue状态
使用 transiton id 或 key 可以进行transiton, 更改issue状态
POST请求
curl -X POST \
http://jira.teamsinspace.com:8080/rest/api/latest/issue/ADR-21/transitions \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
-H 'Content-Type: application/json' \
-d '{
"transition": {
"id": "21"
}
}'
返回结果
204 No Content
Worklog记录工作日志
获取工作日志
使用 GET /rest/api/2/issue/{issueIdOrKey}/worklog API ,
请求消息
curl -X GET \
http://jira.teamsinspace.com:8080/rest/api/latest/issue/ADR-9/worklog \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
返回结果
200 OK
{
"startAt": 0,
"maxResults": 1,
"total": 1,
"worklogs": [
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issue/15060/worklog/13109",
"author": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "tisadmin@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=admin&avatarId=10500",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=admin&avatarId=10500",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=admin&avatarId=10500",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=admin&avatarId=10500"
},
"displayName": "Admin Istrator",
"active": true,
"timeZone": "Asia/Hong_Kong"
},
"updateAuthor": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "tisadmin@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=admin&avatarId=10500",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=admin&avatarId=10500",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=admin&avatarId=10500",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=admin&avatarId=10500"
},
"displayName": "Admin Istrator",
"active": true,
"timeZone": "Asia/Hong_Kong"
},
"comment": "test",
"created": "2018-06-06T06:15:19.745+0000",
"updated": "2018-06-06T06:15:19.745+0000",
"started": "2018-06-06T00:00:00.000+0000",
"timeSpent": "3h",
"timeSpentSeconds": 10800,
"id": "13109",
"issueId": "15060"
}
]
}
记录工作日志
使用 POST /rest/api/2/issue/{issueIdOrKey}/worklog API ,
登记一个3小时的工作
注: JIRA 的REST API 目前为止还不支持为其他用户记录worklog,即便是加了username, 在worklog里还是用REST API验证的那个用户
POST body中的数据内容
{
"comment": " comment by api",
"started": "2018-06-07T09:00:00.000+0000",
"timeSpent": "3h",
}
完整的POST请求
curl -X POST \
http://jira.teamsinspace.com:8080/rest/api/latest/issue/ADR-22/worklog \
-H 'Authorization: Basic YWRtaW46Q2hhcmxpZSE=\n' \
-H 'Content-Type: application/json' \
-d '{
"comment": " comment by api",
"started": "2018-06-07T09:00:00.000+0000",
"timeSpent": "3h"
}'
返回结果
201 Created
{
"self": "http://jira.teamsinspace.com:8080/rest/api/2/issue/15618/worklog/13108",
"author": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "tisadmin@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=admin&avatarId=10500",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=admin&avatarId=10500",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=admin&avatarId=10500",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=admin&avatarId=10500"
},
"displayName": "Admin Istrator",
"active": true,
"timeZone": "Asia/Hong_Kong"
},
"updateAuthor": {
"self": "http://jira.teamsinspace.com:8080/rest/api/2/user?username=admin",
"name": "admin",
"key": "admin",
"emailAddress": "tisadmin@veryrealemail.com",
"avatarUrls": {
"48x48": "http://jira.teamsinspace.com:8080/secure/useravatar?ownerId=admin&avatarId=10500",
"24x24": "http://jira.teamsinspace.com:8080/secure/useravatar?size=small&ownerId=admin&avatarId=10500",
"16x16": "http://jira.teamsinspace.com:8080/secure/useravatar?size=xsmall&ownerId=admin&avatarId=10500",
"32x32": "http://jira.teamsinspace.com:8080/secure/useravatar?size=medium&ownerId=admin&avatarId=10500"
},
"displayName": "Admin Istrator",
"active": true,
"timeZone": "Asia/Hong_Kong"
},
"comment": " comment by api",
"created": "2018-06-06T05:50:45.921+0000",
"updated": "2018-06-06T05:50:45.921+0000",
"started": "2018-06-07T09:00:00.000+0000",
"timeSpent": "3h",
"timeSpentSeconds": 10800,
"id": "13108",
"issueId": "15618"
}