Java 来自GAE地址的getInputStream上的FileNotFoundException
我正在用Python做一个Android应用程序和一个API。API在Google应用程序引擎云上,当我与Postman一起测试时,一切正常 我正在尝试使用POST方法登录。该方法返回json,其中包含我一直得到的用户信息:FileNotFoundException 以下是我的一些代码:Java 来自GAE地址的getInputStream上的FileNotFoundException,java,android,python,google-app-engine,Java,Android,Python,Google App Engine,我正在用Python做一个Android应用程序和一个API。API在Google应用程序引擎云上,当我与Postman一起测试时,一切正常 我正在尝试使用POST方法登录。该方法返回json,其中包含我一直得到的用户信息:FileNotFoundException 以下是我的一些代码: try{ String account = params[0].get(0); String password = params[0].get(1);
try{
String account = params[0].get(0);
String password = params[0].get(1);
URL url = new URL("http", WEB_SERVICE_URL, PORT, REST_LOGIN);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout(CONNECTION_TIMEOUT);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestProperty("Content-Type", "application/json");
httpURLConnection.setRequestProperty("Accept", "application/json");
JSONObject json = jsonParser.serialJsonLogin(nomCompte, motPasse);
osw = new OutputStreamWriter(httpURLConnection.getOutputStream(),"UTF-8");
osw.write(json.toString());
osw.flush();
String body = readStream(httpURLConnection.getInputStream());
osw.close();
Log.i(TAG, "Return : " + body);
user = jsonParser.deserializeJsonUser(body);
}catch (Exception e) {
mException = e;
}finally {
if (mHttpURLConnection != null) {
mHttpURLConnection.disconnect();
}
}
return user;
At:String body=readStream(httpURLConnection.getInputStream());我得到一个java.io.FileNotFoundException:
我的readStream方法很好,我已经测试过了。如果我查看我的谷歌应用程序引擎日志,我可以看到没有404或任何错误。如果我找到了用户,我会得到一个201,如果不是403的话。因此,即使错误为FileNotFound,我也会看到状态代码,这意味着URL实际上是正确的
更新:我的API给了我一个201,而getInputStream显然无法在201状态下工作。在API中将我的退货状态更改为200,效果良好