标签: http-status-code-400

Mercurial不断返回错误400:错误请求

每当我尝试与服务器进行任何交互时,Mercurial都会返回"abort:HTTP Error 400:Bad Request".我们没有使用任何身份验证,因此这不是问题.我们有三个其他开发人员使用相同版本的mercurial安装同一个repo(2.2.3).他们没有任何问题,所以它让我觉得我在.hg文件夹或其他什么东西腐败了.但我真的不知道.

我能够从新目录克隆和工作就好了.然而,大约4个小时后,它也开始在新目录中再次发生.我在那个时期做的唯一事情是提交,拉动和推动.几个小时后我提交并试图拉动,那是我再次收到错误的时候.

这是传入的调试日志(hg --debug --traceback incoming):

using http://myserver/myapp
sending capabilities command
comparing with http://myserver/myapp
query 1; heads
sending batch command
searching for changes
taking initial sample
searching: 2 queries
query 2; still undecided: 208, sample size is: 200
sending known command
Traceback (most recent call last):
File "mercurial\dispatch.pyo", line 88, in _runcatch
File "mercurial\dispatch.pyo", line 740, in _dispatch
File "mercurial\dispatch.pyo", line 514, in runcommand
File "mercurial\dispatch.pyo", line 830, in _runcommand
File "mercurial\dispatch.pyo", line 801, in checkargs
File …
Run Code Online (Sandbox Code Playgroud)

mercurial tortoisehg http-status-code-400

8
推荐指数
1
解决办法
5670
查看次数

如何在jQuery getJSON调用中捕获400响应

在jQuery中我想使用该$.getJSON()方法从facebook获取一些数据,但如果令牌无效,Facebook将返回400状态.我怎样才能捕捉错误$.getJSON()而不是$.ajax()

javascript ajax jquery json http-status-code-400

8
推荐指数
2
解决办法
1万
查看次数

urllib.error.HTTPError:HTTP错误400:错误请求

海兰!我试图打开网页,通常是在浏览器中打开,但是python只是发誓并且不想工作.

import urllib.request, urllib.error
f = urllib.request.urlopen('http://www.booking.com/reviewlist.html?cc1=tr;pagename=sapphire')
Run Code Online (Sandbox Code Playgroud)

另一种方式

import urllib.request, urllib.error
opener=urllib.request.build_opener()
f=opener.open('http://www.booking.com/reviewlist.html?cc1=tr;pagename=sapphi
re')
Run Code Online (Sandbox Code Playgroud)

这两个选项都会出现一种错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python34\lib\urllib\request.py", line 461, in open
    response = meth(req, response)
  File "C:\Python34\lib\urllib\request.py", line 571, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python34\lib\urllib\request.py", line 493, in error
    result = self._call_chain(*args)
  File "C:\Python34\lib\urllib\request.py", line 433, in _call_chain
    result = func(*args)
  File "C:\Python34\lib\urllib\request.py", line 676, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "C:\Python34\lib\urllib\request.py", line 461, in …
Run Code Online (Sandbox Code Playgroud)

python urllib urlopen python-3.x http-status-code-400

8
推荐指数
1
解决办法
2万
查看次数

AxiosError:请求失败,状态代码为 400(在 React JS 中)

我正在尝试使用 axios 发表评论。当我提交在表单中输入的数据时,我在控制台中看到此错误:

\n

AxiosError\xc2\xa0{message: \'请求失败,状态代码 400\',名称:\'AxiosError\',代码:\'ERR_BAD_REQUEST\',配置:{\xe2\x80\xa6},请求:XMLHttpRequest, \xc2\xa0\xe2\x80\xa6}

\n

这是我的代码:

\n
import React, { useState } from \'react\'\nimport TextField from \'@material-ui/core/TextField\';\nimport { Button } from \'@material-ui/core\'\nimport CommentsAPI from \'../../Services/CommentsAPI\'\n\nexport default function CommentForm() {\n\n    const [comment, setComment] = useState({})\n\n    const handleSubmit = async (event) => {\n        event.preventDefault();\n        try {\n            const data = CommentsAPI.create(JSON.stringify(comment))\n            console.log(data)\n        } catch (error) {\n            console.log(error)\n        }\n    }\n\n    const handleChange = (event) => {\n        const {name, value} = event.currentTarget\n        setComment({\n            ...comment,\n            [name]: value\n        })\n    }\n\n    return (\n        <form …
Run Code Online (Sandbox Code Playgroud)

bad-request http-status-code-400 reactjs axios

8
推荐指数
1
解决办法
6万
查看次数

HTTPWebRequest&过了一会儿,400(错误请求)启动

我有一个后台工作线程,它不断地将数据同步到远程服务器或从远程服务器同步数据.当我第一次运行应用程序时,一切似乎都正常.它每30秒发出一次Web请求,数据返回成功.

如果我让模拟器长时间运行,最终请求将因(400)错误请求而失败.所有后续请求都做同样的事情.如果我杀了应用程序并重新启动它...一切都很好.

有人有主意吗?代码如下.

public RestResponse<T> Execute<T>(RestRequest request) {
    var restResponse = new RestResponse<T>();
    var serializer = new JavaScriptSerializer();
    var urlPath = baseUrl + "/" + request.Resource;
    Console.WriteLine("Requesting: " + urlPath);
    var httpRequest = (HttpWebRequest)HttpWebRequest.Create(new Uri(urlPath));

    httpRequest.Headers = request.Headers;
    foreach (string key in clientHeaders.Keys)
        httpRequest.Headers.Add(key, clientHeaders[key]);
    httpRequest.Headers.Add("Accept-Encoding", "gzip,deflate");

    Authenticator.Authenticate(httpRequest);
    httpRequest.Method = request.Method.ToString();       
    HttpWebResponse httpResponse = null;
    try {
        if ((request.Method == Method.POST) && (!request.IsJsonPost))
            SetPostData(httpRequest, request);

        if ((request.Method == Method.POST) && (request.IsJsonPost)){
            SetJsonPostData(httpRequest, request);
        }

        httpResponse = (HttpWebResponse)httpRequest.GetResponse();
        var reader = …
Run Code Online (Sandbox Code Playgroud)

c# mono httpwebrequest xamarin.ios http-status-code-400

7
推荐指数
1
解决办法
6466
查看次数

如何故意在Python/Flask中导致400 Bad Request?

我的REST API的消费者说有时我会返回400 Bad Request- The request sent by the client was syntactically incorrect.错误.

我的应用程序(Python/Flask)日志似乎没有捕获这个,我的webserver/Nginx也没有记录.

编辑:我想尝试在Flask中导致400个错误请求以进行调试.我怎样才能做到这一点?

根据James的建议,我添加了类似于以下内容:

@app.route('/badrequest400')
def bad_request():
    return abort(400)
Run Code Online (Sandbox Code Playgroud)

当我调用它时,flask返回以下HTML,它不使用"客户端发送的请求在语法上不正确"行:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>
Run Code Online (Sandbox Code Playgroud)

(我不确定为什么它不包括<body>标签.

在我看来,400错误消息有不同的变化.例如,如果我将cookie设置为长度为50,000的值(使用Interceptor with Postman),我将从Flask获得以下错误:

<html>
<head>
    <title>Bad Request</title>
</head>
<body>
    <h1>
        <p>Bad Request</p>
    </h1>
Error parsing headers: 'limit request headers fields size'

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

有没有办法让Flask通过400个错误的不同变化?

python rest nginx http-status-code-400 postman

7
推荐指数
3
解决办法
1万
查看次数

在ASP.Net Core中发布表单数据时出现400状态错误

我正在开发一个ASP.Net Core 2.0应用程序并在Linux/Nginx/Kestrel上运行它.

在开发环境(Windows 10)上,一切运行顺利.此外,在项目目录中使用"dotnet run"运行应用程序时.

在生产环境(Debian 8/Kestrel)上,所有表单POST都失败并显示HTTP状态码400(错误请求),而不会在控制台中提示任何错误,而表单GET请求运行正常.控制台中会提示所有其他消息(警告,错误).我正在使用"dotnet .dll"运行应用程序.

有人能指出我解决问题的方向吗?

form-post http-status-code-400 asp.net-core

7
推荐指数
0
解决办法
1441
查看次数

HTTP 404与400的无效查询参数

这是我的请求网址:

http://server.com/app/user/getuser/?userId=9999

注意,这userId是查询参数。未嵌入的路径参数。

我了解如果请求URL为:http : //server.com/app/user/getuser/9999并且ID 9999在数据库中不存在,则应使用404。

但是userId查询参数应使用哪种HTTP状态?现在我返回的是400,而不是404。

query-parameters http-status http-status-code-404 http-status-code-400

7
推荐指数
1
解决办法
2731
查看次数

客户端错误请求400 vs 422

我已经阅读了很多关于正确的http状态代码的帖子和文章,以便返回客户端请求错误.其他人建议使用400,因为它已在RFC 7231中重新定义,但我不确定给出的示例是否涵盖了我脑海中的所有客户端错误,因为这些示例是语法.

400(错误请求)状态代码指示服务器由于被认为是客户端错误(例如,格式错误的请求语法,无效的请求
消息成帧或欺骗性请求路由)而不能或不会处理该请求.

我确实在rfc 7231的附录B中找到了这个陈述:

400(错误请求)状态代码已被放宽,因此
不限于语法错误.(第6.5.1节)

这是否意味着我可以将任何类型的客户端错误视为错误请求?将400用于客户端请求并在消息中指定更具体的错误会更好吗?


另一方面,其他人说最好使用422(不可处理的实体).虽然这更侧重于语义,但它仅在RFC 4918中列出,它是http/1.1的webDAV扩展.

的422(无法处理的实体)状态代码表示该服务器
理解的内容类型的请求实体(因此一个的
415(不支持的媒体类型)状态代码是不适当的),并且
所述请求实体的语法是正确的(因此400(错误的请求)
状态代码不合适)但无法处理包含的指令.例如,如果XML
请求主体包含格式正确(即语法正确)但
语义错误的XML指令,则可能发生此错误情况.

我可以使用此webDAV扩展代码来处理我的http请求吗?在422的情况下,我可以使用它,即使它不在核心http代码中.

我应该使用400或422来解决客户端错误吗?

以下是我想到的可能的客户端错误:

1.) Invalid parameter. The client provided parameters but are found invalid. Example: I said that the userId is 1, but when I checked there's no userId of 1. Another example of invalid parameter is wrong data type.
2.) Missing required parameters
3.) Let's say I need to hash a value based on given params and …
Run Code Online (Sandbox Code Playgroud)

error-handling http-status-codes http-error http-status-code-400 http-status-code-422

7
推荐指数
1
解决办法
3994
查看次数

将 *.googleusercontent.com 添加到 Authorized JavaScript origins

我们有一个 Google Sheets 插件,并且想为某些功能切换其他 Google 帐户。

半年前,我成功添加了一个 URL (https://***.googleusercontent.com) 到Authorized JavaScript origins和一个 URL ( https://oauth-redirect.googleusercontent.com/r/\*\*\ *) 到授权的重定向 URI

但现在我们不能,因此,它一直显示

授权错误(错误:400:redirect_uri_mismatch)。

当我尝试添加此 URL(https://***.googleusercontent.com) 时,它显示

“保存失败!请求失败,因为资源的字段之一无效。”

我不知道规则是否改变了,我该怎么办。有关详细信息,请参阅屏幕截图。谢谢!

错误消息:请求中的 JavaScript 源 https://***.googleusercontent.com 与为 OAuth 客户端授权的源不匹配。

请求中的 JavaScript 源 https://***.googleusercontent.com 与为 OAuth 客户端授权的源不匹配。

尝试添加新的 URI

add-on google-sheets google-apps-script http-status-code-400 google-cloud-platform

7
推荐指数
1
解决办法
812
查看次数