服务器端集成(REST API) 本地测试正常 部署到服务器调用api时异常

请求时使用HttpURLConnection

java.io.IOException: Server returned HTTP response code: 400 for URL:
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$6.run(HttpURLConnection.java:1514)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1508)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1162)
    at java.net.URLConnection.getContent(URLConnection.java:688)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getContent(HttpsURLConnectionImpl.java:406)
已邀请:

ebpangyong

赞同来自: wfh

请求的是哪个接口?从错误看有可能是请求的url有问题,可以打印一下看看

wfh

赞同来自: lizg

已解决,通过getErrorStream看返回结果是字符编码问题

要回复问题请先登录注册

知识价值的认可,源自您的赞赏

扫描二维码,你的支付将由imGeek代收后转给对方

×