HttpPost, posting Array via Multiple entity

Put your problem here if it does not fit any of the other categories.

HttpPost, posting Array via Multiple entity

Postby flagantz » Mon Feb 14, 2011 10:49 am

this is my code

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. HttpClient client = new DefaultHttpClient();  
  3. String postURL = "http://blablabla.com;
  4. HttpPost post = new HttpPost(postURL);
  5.    
  6. String[] my_users = {
  7.                         "User1", "User2", "User3"
  8.                 };
  9.  
  10. MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);  
  11. try {
  12.         reqEntity.addPart("_id", new StringBody("Test"));
  13.         reqEntity.addPart("_users", new StringBody(my_users));
  14. } catch (UnsupportedEncodingException e1) {
  15.         Log.e("Error", "UnsupportedEncodingException");
  16.         e1.printStackTrace();
  17. }
  18. post.setEntity(reqEntity);     
  19. HttpResponse response = client.execute(post);  
  20. HttpEntity resEntity = response.getEntity();
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


it's error on the reqEntity.addPart("_users", new StringBody(my_users)); part bcause my_users is array

i've googling and found nothing, can someone help me on this problem plz..

thanks
flagantz
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Feb 14, 2011 10:36 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 22 guests