gpt4 book ai didi

api - Github API 502 错误

转载 作者:行者123 更新时间:2023-12-04 18:42:44 25 4
gpt4 key购买 nike

我正在尝试通过他们的 API 将用户添加到 Github 存储库,但我总是收到 502 Bad Gateway错误。
使用 curl 我发送这样的请求(<...> 替换为真正的所有者、 repo 等):

curl -i -H 'Authorization: token xxxxxxxxxx' -XPUT https://api.github.com/repos/<owner>/<repo>/collaborators/<username>

我也用这个网址试过了:
curl -i -H 'Authorization: token xxxxxxxxxx' -XPUT https://api.github.com/teams/<id>/members/<username>

作为 token ,我使用了新创建的个人访问 token

但两次我都拿回来了
HTTP/1.0 502 Bad Gateway
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>502 Bad Gateway</h1>
The server returned an invalid or incomplete response.
</body></html>

一个 GET在每个 URL 上工作正常,但 DELETE也不起作用。所以也许它与 curl 有关。

最佳答案

引用 GitHub 支持的回复,斜体更改:

You're just getting trolled by HTTP and curl.

When you make a PUT request with no body, curl doesn't explicitly set a Content-Length header for that request. However, PUT requests with no Content-Length confuse servers and they respond in weird ways.

Can you please try explicitly setting the Content-Lenght header to 0, or supplying an empty body when making that request (so that curl can set the header for you)? You can accomplish that adding

-d ""
in your command.

关于api - Github API 502 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21698009/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com