Java Https Post:AppEngine上的畸形异常
当我通过GAE的身份验证向url发送POST请求时,我在urlConn.getResponseCode()函数上收到了错误的DorLexception 此问题仅在部署服务器上出现,在本地服务器上运行代码时不会出现Java Https Post:AppEngine上的畸形异常,java,google-app-engine,url,http-post,Java,Google App Engine,Url,Http Post,当我通过GAE的身份验证向url发送POST请求时,我在urlConn.getResponseCode()函数上收到了错误的DorLexception 此问题仅在部署服务器上出现,在本地服务器上运行代码时不会出现 Invalid URL specified: https://user:passtoken@twilix.exotel.in/v1/Accounts/user/Sms/send java.net.MalformedURLException: Invalid URL specified:
Invalid URL specified: https://user:passtoken@twilix.exotel.in/v1/Accounts/user/Sms/send
java.net.MalformedURLException: Invalid URL specified: https://user:passtoken@twilix.exotel.in/v1/Accounts/user/Sms/send
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.convertApplicationException(URLFetchServiceImpl.java:120)
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:43)
at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:417)
at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:296)
我的代码:
String urlString =
"https://user:passtoken@twilix.exotel.in/v1/Accounts/user/Sms/send";
URL url = new URL(urlString.toString());
String userpass = "user:passtoken";
String basicAuth = "Basic " +
javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes());
urlConn = (HttpURLConnection) url.openConnection();
urlConn.setRequestMethod("POST");
urlConn.setRequestProperty ("Authorization", basicAuth);
urlConn.connect();
responseCode = urlConn.getResponseCode(); //Throws Exception
当我尝试将url设置为
这是GAE的错误还是我的代码有问题?看起来问题出在符号和符号上。由于您已经将凭据放入HTTP请求中,因此URL中也不需要这些凭据。尝试将第一行改为此
String urlString = "https://twilix.exotel.in/v1/Accounts/user/Sms/send";