使用 Github HTTP Rest API 创建问题会抛出无法处理的实体,即使负载是从文档中按原样复制的

问题描述 投票:0回答:1

我正在尝试运行这个:

curl --location 'https://api.github.com/repos/abc/example/issues' \
--header 'Accept: application/vnd.github+json' \
--header 'Authorization: Bearer <AUTH_TOKEN>' \
--header 'X-GitHub-Api-Version: 2022-11-28' \
--header 'Content-Type: application/json' \
--data '{
  "title": "Found a bug",
  "body": "I'\''m having a problem with this.",
  "milestone": 1,
  "labels": [
    "bug"
  ]
}'

但这返回 422:无法处理的实体:

{
    "message": "Validation Failed",
    "errors": [
        {
            "value": 1,
            "resource": "Issue",
            "field": "milestone",
            "code": "invalid"
        }
    ],
    "documentation_url": "https://docs.github.com/rest/issues/issues#create-an-issue"
}

据我在文档中看到,它需要有一个数字、null 或字符串,但保留 1 不起作用。我想知道我应该在里程碑中添加什么?它必须与某种价值相关联吗?

github-api
1个回答
0
投票

从错误消息来看,您在请求中引用的

milestone
号码似乎不存在。请先阅读 关于里程碑 并创建一个,然后重试您的请求,或者通过从请求 JSON 负载中删除
milestone
字段,不要将问题与任何里程碑关联,因为根据 REST API 文档,该字段是可选的:

milestone
- null 或字符串或整数

与此问题相关联的里程碑的

number
。 _注意:只有具有推送访问权限的用户才能设置新问题的里程碑。

© www.soinside.com 2019 - 2024. All rights reserved.