Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8316587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:23:45+00:00 2026-06-08T21:23:45+00:00

I am suppose to send song (mp3/wav) file and some data through secure restful

  • 0

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.
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:23:46+00:00Added an answer on June 8, 2026 at 9:23 pm

    Try removing the setURI method and passing the URL in when you create your HttpPost object, as follows. This worked for me (more here).

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost postRequest = new HttpPost(ServiceURL);
    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)));     
        postRequest.setEntity(reqEntity);
    
        HttpResponse response = httpclient.execute(postRequest);
    
    } catch (URISyntaxException e) {
        Log.e("URISyntaxException", e.toString());
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I send data with xmpppy using this method: http://xmpp.org/extensions/xep-0047.html#send I suppose I
I have the following code that suppose used to Send Data to Server using
my web application supposed to send email reminders in some point it will send
Suppose you connected to a server through socket connection and for onetime you send
Suppose I'm writing some environment which execute clients code (Java). Clients send jar with
in other words, suppose I want to send data, like text, programmatically from a
Suppose that, we're expecting just strings or numbers with the data send by a
Suppose that I want my ASP.net web server to open a file and then
My website shows recommend pages for users. Right now, I suppose to send a
Suppose I have an action that returns an rendered asp.net mvc control and send

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.