Java 服务器返回 HTTP 响应代码:GET 请求的 URL 为 500

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21588061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 09:31:40  来源:igfitidea点击:

Server returned HTTP response code: 500 for URL for GET request

javaresthp-quality-center

提问by theJ

I'm trying to query ALM defects with a filter condition, but I get the below exception. The same URL is working fine when accessed through a browser.

我正在尝试使用过滤条件查询 ALM 缺陷,但出现以下异常。通过浏览器访问时,相同的 URL 工作正常。

java.io.IOException: Server returned HTTP response code: 500 for URL:
http://ealm11.mycomp.com:80/qcbin/rest/domains/TESTING/projects/2014/defects?query={owner['das'  or 'john' or 'kim'];status[Assigned]}&fields=id    at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at
sun.net.www.protocol.http.HttpURLConnection.run(HttpURLConnection.java:1491)
    at java.security.AccessController.doPrivileged(Native Method)   at
sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1485)
    at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139)

Also, if the URL does not have the "or" condition in one of the param values as below

此外,如果 URL 在以下参数值之一中没有“或”条件

http://ealm11.mycomp.com:80/qcbin/rest/domains/TESTING/projects/2014/defects?query={owner['das'];status[Assigned]}&fields=id

it's working but when i introduce "or" conditions, java is throwing the above error.

它正在工作,但是当我引入“或”条件时,java 会抛出上述错误。

采纳答案by Alvin Bunk

Have you tried with a "%20" for spaces in the URL?

您是否尝试过在 URL 中使用“%20”作为空格?

http://ealm11.mycomp.com:80/qcbin/rest/domains/TESTING/projects/2014/defects?query={owner['das'%20or%20'john'%20or%20'kim'];status[Assigned]}&fields=id

回答by Christian Kuetbach

Errorcodes from 500and upwards are errors at serverside.

自上而下500的错误代码是服务器端的错误。

This means you can't do anything against it.

这意味着你不能对它做任何事情。

But in fact I think, it should be a 406 Bad Requestand you did a malformed request and the server has an error which throws an exception.

但实际上我认为,它应该是一个406 Bad Request并且你做了一个格式错误的请求并且服务器有一个错误抛出异常。

Are you sure, that ORis valid for this request?

你确定,这OR对这个请求有效吗?

UpdateYou may need to urlencode your query(only true for the query part). Browser are encoding automatic, java not.

更新您可能需要对您的查询进行urlencode(仅适用于查询部分)。浏览器是自动编码的,java 不是。