为什么我的Gitlab请求总是返回错误400 [英] Why does my Gitlab Requests always return a Error 400
问题描述
当我调用Gitlab API时,搜索名为Edbtvplays的用户时出现此错误.
When i call the Gitlab API, searching for a User named Edbtvplays i get this Error.
我尝试将Python之外的API卷曲,但我没有收到此错误
i have tried curling the API outside of python and i do not recieve this error
import requests
r = requests.post("https://git.deploys.io/api/v4/users?username=Edbtvplays", headers={"PRIVATE-TOKEN":"Removed Token"})
print(r)
它应该返回[],就像没有找到用户一样,或者应该返回包含用户信息的json
It should return [] as if no user was found or it should return a json with the Users information
推荐答案
Check out what is returned: the GitLab Users API page does mention:
如果发生错误,则返回
400错误请求
,并附有一条解释该错误的消息.
If an error occurs a
400 Bad Request
is returned with a message explaining the error.
那是服务器端问题,例如 gitlab-com/support-forum
问题2720
That, or it is a server-side issue, as in gitlab-com/support-forum
issue 2720
这400个错误是由服务器端检查引起的,该检查需要提供
User-Agent
标头.
这就是为什么只有特定的客户会受到影响的原因.
The 400 errors were caused by a server side check that required a
User-Agent
header to be provided.
That's why only particular clients were affected.
这篇关于为什么我的Gitlab请求总是返回错误400的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!