Github rest api后标签为数组输入提供错误
我们正在为我们的发展托管GitHub enterprise。我能够访问重置api并创建jira、创建PR等 当我返回我的PR时,它给出了数组的错误Github rest api后标签为数组输入提供错误,github,github-api,Github,Github Api,我们正在为我们的发展托管GitHub enterprise。我能够访问重置api并创建jira、创建PR等 当我返回我的PR时,它给出了数组的错误 curl -X POST -u githuser:gittoken https://api.github.mycompany.com/repos/team/repo/issues/560/labels -H "Content-type: application/json" -k -d '{"labels": ["bug"]}' -H "Accept:
curl -X POST -u githuser:gittoken https://api.github.mycompany.com/repos/team/repo/issues/560/labels -H "Content-type: application/json" -k -d '{"labels": ["bug"]}' -H "Accept: application/json"
{
"message": "Invalid request.\n\nFor 'links/2/schema', {\"labels\"=>[\"bug\"]} is not an array.",
"documentation_url": "https://developer.github.com/enterprise/2.13/v3/issues/labels/#add-labels-to-an-issue"
}
我检查,bug
是有效标签
curl -u githuser:gittoken -X GET \
https://api.github.mycompany.com/repos/team/repo/labels
[
{
"id": 163461,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/+1",
"name": "+1",
"color": "c2e0c6",
"default": false
},
{
"id": 382069,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/Blocked",
"name": "Blocked",
"color": "fbca04",
"default": false
},
{
"id": 163462,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/Changes%20Requested",
"name": "Changes Requested",
"color": "cc317c",
"default": false
},
{
"id": 404926,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/Release%20Review",
"name": "Release Review",
"color": "5319e7",
"default": false
},
{
"id": 228780,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/Review%20Pass",
"name": "Review Pass",
"color": "009800",
"default": false
},
{
"id": 228781,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/Review%20Requested",
"name": "Review Requested",
"color": "eb6420",
"default": false
},
{
"id": 426113,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/Staging%20Bug",
"name": "Staging Bug",
"color": "d6021a",
"default": false
},
{
"id": 163457,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/bug",
"name": "bug",
"color": "fc2929",
"default": true
},
{
"id": 163458,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/duplicate",
"name": "duplicate",
"color": "cccccc",
"default": true
},
{
"id": 163459,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/enhancement",
"name": "enhancement",
"color": "84b6eb",
"default": true
},
{
"id": 163460,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/help%20wanted",
"name": "help wanted",
"color": "159818",
"default": true
},
{
"id": 163463,
"url": "https://github.mycompany.com/api/v3/repos/team/repo/labels/wontfix",
"name": "wontfix",
"color": "ffffff",
"default": true
}
]
我尝试了其他组合,比如纯字符串、带昏迷的字符串等。。但同样的错误
实际指挥:
它与
curl -X POST -u githuser:gittoken \
https://api.github.mycompany.com/repos/team/repo/issues/560/labels \
-H "Content-type: application/json" -k \
-d '["bug"]' \
-H "Accept: application/json"
下面的文档有如下示例:
{
"labels": ["bug", "enhancement"]
}
但是还有另一个Enterprise
文档显示它应该是[“bug”]
而不是字典。它可以与
curl -X POST -u githuser:gittoken \
https://api.github.mycompany.com/repos/team/repo/issues/560/labels \
-H "Content-type: application/json" -k \
-d '["bug"]' \
-H "Accept: application/json"
下面的文档有如下示例:
{
"labels": ["bug", "enhancement"]
}
但是还有另一个Enterprise
文档显示它应该只是[“bug”]
而不是字典。Python工作示例
import requests
url = f'https://api.github.com/repos/your/url/issues/{issue_number/pr_number}'
data = {"labels": [your_label/list_of_labels]}
requests.patch(url, auth=auth, json=data)
Python工作示例
import requests
url = f'https://api.github.com/repos/your/url/issues/{issue_number/pr_number}'
data = {"labels": [your_label/list_of_labels]}
requests.patch(url, auth=auth, json=data)
你能准确地提供你正在做的卷曲吗?据我所知,您的CURL是正确的,但我希望看到您正在执行的确切CURL。@我在main中添加了实际命令question@ConfusedDeer你从实际的命令中有什么想法吗?你有没有试着在URL前面加上-d'{“labels”:[“bug”]}?@confusedeer我发布了答案,引起问题的不是
-d
,而是数据。您能准确地提供您正在做的卷曲吗?据我所知,您的CURL是正确的,但我希望看到您正在执行的确切CURL。@我在main中添加了实际命令question@ConfusedDeer你从实际的命令中有什么想法吗?你有没有试着在URL前面加上-d'{“labels”:[“bug”]}?@confusedeer我发布了答案,引起问题的不是-d
,而是数据
。你能试试curl
?@nilesh-看起来你的curl还可以,只是你用的是POST而不是补丁。尝试使用补丁请求。请参阅-您可以尝试使用curl
?@nilesh-看起来您的curl还可以,只是您使用的是POST而不是PATCH。尝试使用补丁请求。见-和