一切正常,直到我在我的网站上安装SSL证书,现在我从android使用IIS 10连接到c#Web api时收到此错误。我的代码适用于android 6及更高版本,但不适用于android 4。 这是我的代码
protected String doInBackground(String... strings) {
List<File> mFiles=new ArrayList<>();
String urlString = Common.URL+"SaveImage";
try {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(urlString);
final List<FileBody> mFileBody=new ArrayList<>();
for(int i=0;i<Common.ImagePathList.size();i++){
FileBody bin1 = new FileBody(new File(Common.ImagePathList.get(i)));
mFileBody.add(bin1);
}
Looper.prepare();
MultipartEntityBuilder reqEntity = MultipartEntityBuilder.create();
reqEntity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
for(int i=0;i< mFileBody.size();i++){
reqEntity.addPart("Photo"+i,mFileBody.get(i));
}
// reqEntity.addTextBody("size",""+Common.ImagePathList.size(), cz.msebera.android.httpclient.entity.ContentType.parse(ContentType.TEXT_PLAIN));
reqEntity.addTextBody("adId",Common.AdId);
post.setEntity((HttpEntity) reqEntity.build());
//socketFactory.createSocket().connect(client.);
HttpResponse response = client.execute(post);
HttpEntity resEntity = response.getEntity();
final String response_str = EntityUtils.toString(resEntity);
if (resEntity != null) {
Log.i("RESPONSE", response_str);
runOnUiThread(new Runnable() {
public void run() {
try {
mFileBody.clear();
} catch (Exception e) {
e.printStackTrace();
}
}});
return response_str;
}
} catch (Exception ex){
Log.e("Debug", "error: " + ex.getMessage(), ex);
Toast.makeText(getApplicationContext(), ""+ ex.getMessage(), Toast.LENGTH_LONG).show();
}
return null;
}
我尝试了邮递员,看是否是服务器问题,但在邮递员中工作正常,但从邮递员复制Java自动代码在android中不起作用,并产生了Response code 400
预先感谢