添加一条任务

添加一条任务

API调用URL地址

  1. 创建普通任务  http://<serverName>:<portNumber>/api/v3/tasks
  2. 创建请求任务  http://<serverName>:<portNumber>/api/v3/requests/{id}/tasks
  3. 创建问题任务  http://<serverName>:<portNumber>/api/v3/problems/{id}/tasks
  4. 创建变更任务  http://<serverName>:<portNumber>/api/v3/changes/{id}/tasks
  5. 创建项目任务  http://<serverName>:<portNumber>/api/v3/projects/{id}/tasks
  6. 创建里程碑任务  http://<serverName>:<portNumber>/api/v3/projects/{project_id}/milestones/{milestone_id}/tasks

其中{id}为需要添加任务的请求/问题/变更/项目 ID。{project_id}为里程碑所属项目id, {milestone_id}为里程碑id。

示例:http://192.168.0.163:8080/api/v3/tasks

请求参数

方法:POST

请求参数:

参数名

位置

input_data

<JSON_String>

body

authtoken

<API Key>

header

输入示例

 {

    "task":{
        "percentage_completion":6,
        "email_before":3600000,
        "description":"测试任务描述",
        "title":"测试任务主题",
        "additional_cost":"2.20",
        "actual_end_time":{
            "value":1583814450059
        }
,
        "actual_start_time":{
            "value":1483814450059
        }
,
        "owner":{
            "id":6
        }
,
        "priority":{
            "name":"Low"
        }
,
        "scheduled_end_time":{
            "value":1683814450059
        }
,
        "estimated_effort_hours":"2",
        "estimated_effort_days":"2",
        "estimated_effort_minutes":"22",
        "scheduled_start_time":{
            "value":1583814450059
        }
,
        "status":{
            "name":"open"
        }

    }

}


字段名

释义

备注

percentage_completion

百分比完成度

0-100

email_before

提前提醒时间

界面中为下拉列表值为:不刷新,15分,30分,45分,1小时,2小时,6小时,12小时,1天,2天,1周。所以仅当email_before为对应值的毫秒值时才能在页面显示,其它的值能保存但不能展示在页面上

description

描述

 

title

标题

 

additional_cost

附加成本

 

actual_end_time

实际结束时间

value值为毫秒值时间戳

actual_start_time

实际开始时间

value值为毫秒值时间戳

owner

所有者

 

priority

优先级

 

scheduled_end_time

计划结束时间

value值为毫秒值时间戳

estimated_effort_hours

预估工作量(小时)

在REST API界面测试差别,请以实际使用为准。

estimated_effort_days
预估工作量(天)

estimated_effort_minutes
预估工作量(分钟)

scheduled_start_time

计划开始时间

value值为毫秒值时间戳

status

状态

 


响应示例

{
    "task":{
        "percentage_completion":"6",
        "estimated_effort_hours":"2 小时 ",
        "email_before":"3600000",
        "description":"测试任务描述",
        "title":"测试任务主题",
        "overdue":"false",
        "additional_cost":"2.20",
        "actual_end_time":{
            "display_value":"10/03/2020 12:27 PM",
            "value":"1583814450059"
        }
,
        "id":"22",
        "actual_start_time":{
            "display_value":"08/01/2017 02:40 AM",
            "value":"1483814450059"
        }
,
        "group":null,
        "owner":{
            "email_id":null,
            "name":"Shawn Adams",
            "profile_pic":{
                "content-url":"/images/default-profile-pic2.svg",
                "name":"default-profile-pic2.svg"
            }
,
            "is_vipuser":false,
            "id":"6"
        }
,
        "associated_entity":"general",
        "priority":{
            "color":"#666666",
            "name":"Low",
            "id":"1"
        }
,
        "created_by":{
            "email_id":"test1@test.com",
            "name":"administrator",
            "profile_pic":{
                "content-url":"/images/default-profile-pic2.svg",
                "name":"default-profile-pic2.svg"
            }
,
            "is_vipuser":false,
            "id":"5"
        }
,
        "scheduled_end_time":{
            "display_value":"11/05/2023 10:14 PM",
            "value":"1683814450059"
        }
,
        "marked_owner":null,
        "marked_group":null,
        "estimated_effort_minutes":"22 分",
        "comment":null,
        "created_date":{
            "display_value":"25/11/2021 02:08 PM",
            "value":"1637820526337"
        }
,
        "estimated_effort_days":"2 天 ",
        "task_type":null,
        "scheduled_start_time":{
            "display_value":"10/03/2020 12:27 PM",
            "value":"1583814450059"
        }
,
        "status":{
            "color":"#0066ff",
            "name":"Open",
            "id":"2"
        }

    }
,
    "response_status":{
        "messages":[
            {
                "type":"success",
                "message":"成功添加新的任务。",
                "status_code":"200"
            }

        ]
,
        "status":"success"
    }

}

Postman示例

 

Python脚本示例

#Python version - 3.9
#需要安装requests模块
import requests
 
url = "http://192.168.0.163:8080/api/v3/tasks"
headers = {"authtoken":"2D02FD93-9BD8-484E-ADEF-727FA69A161B"}
input_data = '''{
    "task": {
        "percentage_completion": 6,
        "email_before": 3600000,
        "description": "测试任务描述",
        "title": "测试任务主题",
        "additional_cost": "2.20",
        "actual_end_time": {
            "value": 1583814450059
        },
        "actual_start_time": {
            "value": 1483814450059
        },
        "owner": {
            "id": 6
        },
        "priority": {
            "name": "Low"
        },
        "scheduled_end_time": {
            "value": 1683814450059
        },
        "estimated_effort_hours": "2",
        "estimated_effort_days": "2",
        "estimated_effort_minutes": "22",
        "scheduled_start_time": {
            "value": 1583814450059
        },
        "status": {
            "name": "open"
        }
    }
}'''
data = {'input_data': input_data}
response = requests.post(url,headers=headers,data=data,verify=False)
print(response.text)