跳转至

创建企业里程碑

POST /api/v8/enterprises/{enterprise}/milestones

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

访问令牌支持说明

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

是否允许匿名访问

此接口不允许匿名访问

请求参数

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

Request Body:

请求体为 JSON 对象,包含待创建的里程碑信息:

{
  "$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"
    },
    "due_date": {
      "description": "截止时间,格式 %Y-%m-%d",
      "type": "string"
    },
    "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 不能为空",
  "field": "title"
}

401 未认证

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

Note: 以上失败响应仅为示例,实际错误字段名以后端返回为准。

HTTP 响应状态码

状态码 说明
200 成功(OK)
400 参数错误(Bad request)
401 需要认证(Requires authentication)
403 禁止访问(Forbidden)
404 请求路径不存在(Not found)
500 系统内部错误(Internal server error)

请求示例

参数说明

<enterprise> 替换为企业id(企业空间地址 path);<token> 替换为你的 AtomGit 用户访问令牌。

cURL

curl -X POST 'https://api.atomgit.com/api/v8/enterprises/<enterprise>/milestones?access_token=<token>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{
    "title": "v1.0",
    "description": "发布 v1.0 版本",
    "start_date": "2026-01-01",
    "due_date": "2026-03-31",
    "projects": [1, 2]
  }'

JavaScript

// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v8/enterprises/<enterprise>/milestones?access_token=<token>", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json"
  },
  body: JSON.stringify({
    title: "v1.0",
    description: "发布 v1.0 版本",
    start_date: "2026-01-01",
    due_date: "2026-03-31",
    projects: [1, 2]
  })
});

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

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

Python

import requests

resp = requests.post(
    "https://api.atomgit.com/api/v8/enterprises/<enterprise>/milestones",
    params={"access_token": "<token>"},
    headers={"Content-Type": "application/json"},
    json={
        "title": "v1.0",
        "description": "发布 v1.0 版本",
        "start_date": "2026-01-01",
        "due_date": "2026-03-31",
        "projects": [1, 2],
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

响应示例

状态码: 200

{
  "id": 1,
  "title": "v1.0",
  "description": "发布 v1.0 版本",
  "state": "open",
  "created_at": "2026-10-14T03:19:46Z",
  "updated_at": "2026-10-14T03:19:46Z",
  "due_date": "2026-03-31",
  "start_date": "2026-01-01",
  "projects": ["1", "2"]
}

错误码

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

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