HTTP 400 Bad Request在将更多字符与URL一起发送到服务器时。

huangapple go评论139阅读模式
英文:

HTTP 400 Bad Request while sending more number of characters with the URL to server

问题

我正在开发一个React应用程序,使用fetch API,我正在向服务器发送一个请求,同时在URL中附带一些查询参数。
在Chrome浏览器中,当URL中的字符长度超过7700个字符时,会收到400 Bad Request的错误。

const requestOptions = {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ 参数名: 参数值 })
};
fetch(URL, requestOptions)

请帮助我解决这个问题。

英文:

I am developing one React application, using the fetch API, I am sending one request along with some query parameters in the URL to server.
Getting 400 bad request when the length of the characters in the URL exceeds 7700 characters in the chrome browser.

const requestOptions = {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ parametername: parametervalue})
};
fetch(URL, requestOptions)

HTTP 400 Bad Request在将更多字符与URL一起发送到服务器时。
Please help me with how to fix it.

答案1

得分: 1

根据这个信息,您不能拥有超过7000个字符长的URL。考虑找到另一种实现方式?

英文:

https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers

According to this, you can't have url that is 7000+ characters long. Consider finding a different way to implement?

huangapple
  • 本文由 发表于 2020年7月31日 00:44:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/63177705.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定