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 8885423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:18:30+00:00 2026-06-14T21:18:30+00:00

curl -F file=@/path/to/index.html -u lslkdfmkls@gmail.com -F ‘data={title:API V1 App,package:com.alunny.apiv1,version:0.1.0,create_method:file}’ https://build.phonegap.com/api/v1/apps I am trying to

  • 0
curl -F file=@/path/to/index.html -u lslkdfmkls@gmail.com -F 'data={"title":"API V1  App","package":"com.alunny.apiv1","version":"0.1.0","create_method":"file"}' https://build.phonegap.com/api/v1/apps 

I am trying to achieve the same using a java program using HttpClient library.

DefaultHttpClient client = new DefaultHttpClient(); 
HttpHost targetHost = new HttpHost("build.phonegap.com", 443, "https"); 
client.getCredentialsProvider().setCredentials( 
new AuthScope(targetHost.getHostName(), targetHost.getPort(),AuthScope.ANY_REALM), 
new UsernamePasswordCredentials("abc@gmail.com", "abc123")); 

String authToken = "?auth_token=abcdefgh"; 

HttpPost httpPost = new HttpPost("https://build.phonegap.com/api/v1/apps" + authToken ); 

String jsonString = "{\"title\":\"API V1 App\",\"create_method\":\"file\"}"; 
MultipartEntity multipartEntity = new MultipartEntity(); 
multipartEntity.addPart(new FormBodyPart("data", new StringBody(jsonString))); 
multipartEntity.addPart("file", new FileBody(new File("C:/Users/Desktop/app.zip"))); 

/*StringEntity entity = new StringEntity(jsonString, "UTF-8"); */
httpPost.setEntity(multipartEntity);  

System.out.println("executing request " + httpPost.getRequestLine()); 
HttpResponse httpResponse = client.execute(httpPost); 
HttpEntity entity = httpResponse.getEntity(); 
System.out.println(httpResponse.getStatusLine()); 
if(entity != null ){ 
System.out.println(EntityUtils.toString(entity)); 
} 

In the above code I can only set StringEntity or FileEntity but not both and I think this is what is required to get the functionality of the curl command.

After trying with StringEntity and FileEntity I tried with MultipartEntity but no luck..
Can you please provide me with more details and if possible an example..

Thanks in advance.

  • 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-14T21:18:31+00:00Added an answer on June 14, 2026 at 9:18 pm

    One has to instantiate the MultipartEntity as follows:

    MultipartEntity multipartEntity = new MultipartEntity(
                                             HttpMultipartMode.BROWSER_COMPATIBLE 
                                                           ) ;
    

    This worked for me.

    By default the MultipartEntity is instantiated with HttpMultipartMode.STRICT mode which is documented in the javadocs as “RFC 822, RFC 2045, RFC 2046 compliant” .

    Can someone brief out the RFC’s mentioned here for clear understanding..

    Thanks a Lot

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Configuration File Path : /etc/php.ini Additional .ini files under /etc/php.d : curl.ini, fileinfo.ini,gd.ini,json.ini, mysql.ini,
I'm trying to download an html file with curl in bash. Like this site:
I'm using cURL to get the XML file for my Twitter friend's timeline. (API
My code for RESTful file upload : @Path(/upload) @POST @Consumes(multipart/form-data) public String post( @FormDataParam(part)
I would like to find if this file /path/to/file/profile.yaml contains the folowing values: Cpanel::Easy::PHP5::Curl:
I am using curl like this: curl -s -F uploaded_file=@/path_to_file;type=text/html -F output=soap12 http://localhost/w3c-markup-validator/check >text.xml
I am about to trigger a call to a PHP file via curl in
I am indexing the file using php curl library. I am stuck here with
I have read that CURL is way too fast than File Get Contents and
I write curl php script which work is download csv file from one website

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.