且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么我收到Http/1.1 400错误的请求?

更新时间:2022-04-29 06:11:35

如果HTTP服务认为您发送的是无效/错误/不当内容,则会发送400响应.无法从您的代码中得知实际发送的参数是什么,或者(更重要的是)服务器希望您发送的参数.

A HTTP service will send a 400 response if it thinks you have sent an invalid / incorrect / inappropriate. There is no way to tell from your code, what the actual arguments sent will be, or (more important) what the server expects you to send.

要对此进行诊断,您将需要:

To diagnose this you will need to:

  • 找出您的代码实际发送的内容,并且
  • 找出服务器希望您发送的内容.

第二个可能涉及:

  • 查看具有网络浏览器的普通用户用来发出请求的网页,
  • 查看您从服务器获得的400条响应的正文,
  • 查看服务器日志,和/或
  • 查看服务器的Web API文档(或源代码).

在这种情况下,似乎需要提供一个额外的 token 参数.

In this case, it looks like there is an extra token parameter that needs to be supplied.

但是,我怀疑您可能完全采用了错误的方法."identi.ca"站点使用StatusNet,该网络具有两个已发布的API 用于客户端.没有提及我能看到的登录" URL.

However, I suspect that you might be taking the wrong approach entirely. The "identi.ca" site uses StatusNet which has a couple of published APIs for clients. There's no mention of talking to the "login" URL that I could see.