跳转至

修改企业里程碑

PUT /api/v8/enterprises/{enterprise}/milestones/{milestone_id}

用户调用此接口,进行修改企业里程碑操作。

访问令牌支持说明

  • AtomGit 用户访问令牌(AtomGit user access tokens)

是否允许匿名访问

此接口不允许匿名访问

请求参数

参数名 位置 类型 必填 说明
enterprise path string 是 企业id
milestone_id path string 是 里程碑id
access_token query string 是 用户授权码

Request Body:

请求体为 JSON 对象,包含需要修改的里程碑字段;title 为必填字段。

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "title": {
      "description": "名称",
      "type": "string"
    },
    "description": {
      "description": "描述",
      "type": "string"
    },
    "start_date": {
      "description": "开始时间,格式 %Y-%m-%d",
      "type": "string",
      "format": "date"
    },
    "due_date": {
      "description": "截止时间,格式 %Y-%m-%d",
      "type": "string",
      "format": "date"
    },
    "state_event": {
      "description": "里程碑状态。开启:active;关闭:closed",
      "type": "string",
      "enum": ["active", "closed"]
    },
    "projects": {
      "description": "关联的项目",
      "type": "array",
      "items": {
        "type": "integer"
      }
    }
  },
  "required": ["title"]
}

响应参数

字段 类型 必返 可为空 说明
id integer 是 否 里程碑 id
title string 是 否 标题
description string 是 否 描述
state string 是 否 状态
created_at string 是 否 创建时间
updated_at string 是 否 更新时间
due_date string 否 是 截止时间
start_date string 否 是 开始时间
projects string[] 是 否 关联的项目

失败响应

400 参数错误

{
  "error": "invalid_request",
  "message": "参数 title 不能为空"
}

401 未认证

{
  "error": "unauthorized",
  "message": "缺少或无效的访问令牌"
}

404 未找到

{
  "error": "not_found",
  "message": "企业或里程碑不存在"
}

Note: 错误响应字段名以后端实际返回为准,这里仅示意通用结构。

HTTP 响应状态码

状态码 说明
200 成功(OK)
400 参数错误(Bad request)
401 需要认证(Requires authentication)
403 禁止访问(Forbidden)
404 未找到(Not found)
429 请求过于频繁,触发限流(Too many requests)
500 系统内部错误(Internal server error)

请求示例

参数说明

<enterprise> 替换为企业 id; <milestone_id> 替换为里程碑 id; <token> 替换为你的 AtomGit 用户访问令牌。

cURL

curl -X PUT 'https://api.atomgit.com/api/v8/enterprises/<enterprise>/milestones/<milestone_id>?access_token=<token>' -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"title":"3.0 版本里程碑","description":"3.0 版本规划","start_date":"2026-10-01","due_date":"2026-12-31","state_event":"active","projects":[1,2]}'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v8/enterprises/<enterprise>/milestones/<milestone_id>?access_token=<token>", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json",
  },
  body: JSON.stringify({
    title: "3.0 版本里程碑",
    description: "3.0 版本规划",
    start_date: "2026-10-01",
    due_date: "2026-12-31",
    state_event: "active",
    projects: [1, 2],
  }),
});

if (!response.ok) {
  throw new Error(`请求失败: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.put(
    "https://api.atomgit.com/api/v8/enterprises/<enterprise>/milestones/<milestone_id>",
    params={"access_token": "<token>"},
    headers={
        "Content-Type": "application/json",
        "Accept": "application/json",
    },
    json={
        "title": "3.0 版本里程碑",
        "description": "3.0 版本规划",
        "start_date": "2026-10-01",
        "due_date": "2026-12-31",
        "state_event": "active",
        "projects": [1, 2],
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

{
  "id": 8,
  "title": "3.0 版本里程碑",
  "description": "3.0 版本规划",
  "state": "active",
  "created_at": "2026-09-01T10:00:00+08:00",
  "updated_at": "2026-10-14T03:29:29+08:00",
  "due_date": "2026-12-31",
  "start_date": "2026-10-01",
  "projects": ["project-a", "project-b"]
}

错误码

错误码 说明
401 未认证或凭证无效(缺少/无效的访问凭证)
400 参数错误或请求无法解析
404 请求路径不存在
405 请求方法不支持
429 请求过于频繁,触发限流
500 系统内部错误

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc