KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am suppose to send song (mp3/wav) file and some data through secure restful web service. I am using MultipartEntity to make HttpPost request. but When I execute it through HttpClient, the server replies this error HTTP Status 400 - Bad Request type: Status report message : Bad Request The request sent by the client was syntactically incorrect (Bad Request). But the service is doing very well if we call it from its Web interface. please help its the code HttpClient httpclient = new DefaultHttpClient(); HttpPost postRequest = new HttpPost(); try { MultipartEntity reqEntity = new MultipartEntity(); reqEntity.addPart("email", new StringBody("test@testmail.com")); reqEntity.addPart("password", new StringBody("123")); reqEntity.addPart("title", new StringBody("My new song")); reqEntity.addPart("musicData", new FileBody(new File(FilePath))); // FIlePath is path to file and contains correct file location postRequest.setEntity(reqEntity); postRequest.setURI(new URI(ServiceURL)); HttpResponse response = httpclient.execute(postRequest); } catch (URISyntaxException e) { Log.e("URISyntaxException", e.toString()); } I also included apache-mime4j, httpclient, httpcore and httpmime jars for MultipartEntity. This is HTML page snap for the Service.
Tags (comma-separated)
Save Edits
Cancel