简体   繁体   English

如何使用GitHub API删除存储库?

[英]How to delete a repository using GitHub API?

So I'm trying to delete a bunch of repos (where I'm the contributor) from a dummy organisation where I'm the owner. 因此,我正在尝试从我是所有者的虚拟组织中删除一堆回购协议(我是贡献者)。 I'm following the GitHub documentation here - https://developer.github.com/v3/repos/#delete-a-repository 我在这里关注GitHub文档-https: //developer.github.com/v3/repos/#delete-a-repository

Since it's a GitHub Enterprise account, the URL endpoint is slightly different. 由于它是GitHub Enterprise帐户,因此URL端点略有不同。

Here's my cURL command which is throwing errors for me: 这是我的cURL命令,它为我抛出错误:

curl -i -H 'Authorization: token {token}' DELETE 'https://{hostname}/api/v3/repos/{myUsername}/{reponame}'

Is there something very wrong I'm doing? 我在做错什么吗? I've tried different combinations after looking up a similar question on here but nothing seems to work. 在这里查找类似问题后,我尝试了不同的组合,但似乎无济于事。

Here's the cURL output: 这是cURL输出:

curl: (6) Could not resolve host: DELETE
HTTP/1.1 404 Not Found
Server: GitHub.com
Date: Thu, 14 Sep 2017 16:45:20 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 102
Status: 404 Not Found
X-OAuth-Scopes: repo, user
X-Accepted-OAuth-Scopes: repo
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
X-GitHub-Request-Id: ce484b8e-e6fb-41b3-aaca-65b047be1e3f
Content-Security-Policy: default-src 'none'
Strict-Transport-Security: max-age=31536000; includeSubdomains
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/enterprise/2.9/v3"
}

When the documentation says: 当文档说:

DELETE /repos/:owner/:repo

It is instructing you to use the HTTP verb "DELETE", which is done in curl using "-X DELETE": 它指示您使用HTTP动词“ DELETE”,该动词使用“ -X DELETE”在curl中完成:

curl -i -X DELETE -H 'Authorization: token {token}' 'https://{hostname}/api/v3/repos/{myUsername}/{reponame}'

(I haven't tested this yet, so there may be other issues, but hopefully it will help as a start.) (我尚未对此进行测试,因此可能还有其他问题,但希望它会有所帮助。)

Your curl request is wrong. 您的卷曲请求是错误的。 Below should work: 下面应该工作:

curl -i -H 'Authorization: token {token}' -X 'DELETE' 'https://{hostname}/api/v3/repos/{myUsername}/{reponame}'

DELETE here is a HTTP method just like GET and POST. 这里的DELETE是一个HTTP方法,就像GET和POST一样。 In curl, you need to specify the HTTP method in -X parameter. 在curl中,您需要在-X参数中指定HTTP方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM