首页 文章

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

提问于
浏览
0

所以我是一个虚拟组织的贡献者,我在这里遵循GitHub文档'm the owner. I' - https://developer.github.com/v3/repos/#delete-a-repository

由于它是GitHub Enterprise帐户,因此URL endpoints 略有不同 .

这是我的cURL命令,它为我抛出错误:

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

我有什么不对劲吗?在这里查找类似的问题之后我尝试了不同的组合,但似乎没有任何效果 .

这是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"
}

2 回答

  • 1

    你的卷曲请求是错误的 . 下面应该工作:

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

    DELETE这里是一个HTTP方法,就像GET和POST一样 . 在curl中,您需要在-X参数中指定HTTP方法 .

  • 1

    当文件说:

    DELETE /repos/:owner/:repo
    

    它指示您使用HTTP动词“DELETE”,这是使用“-X DELETE”在curl中完成的:

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

    (我还没有测试过,所以可能还有其他问题,但希望它会有所帮助 . )

相关问题