private void CreateaMultiPartRequest() {
try{
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("http://172.16.22.232:8080/RESTfulExample/rest/multiPartFileUpload");
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
post.setHeader("Content-type", "multipart/form-data; boundary="+"~~~~~");
String Usersettings = "{\"uId\":\"atcc02\", \"bomId\":\"IC014654_12345\", \"fileName\":\"file_12345.pdf\"}";
File cfile = new File(receivedUri.getPath());
reqEntity.addPart("file", new FileBody(cfile,"application/octet"));
reqEntity.addPart("settings", new StringBody(Usersettings,"application/json",Charset.forName("UTF-8")));
post.setEntity(reqEntity);
HttpResponse response = client.execute(post);
HttpEntity resEntity = response.getEntity();
if (resEntity != null)
{
resEntity.consumeContent();
}
else{
}
}
catch(Exception e)
{
}
}
このコードを実行しようとすると、サーバーから「400:BAD REQUEST」が返されます。ここで問題を解決できません。この問題を解決するのを手伝ってもらえますか?