Hi Android Experts, i need to make a GET request to the http://www.x.com/server.xml which takes 3 mandatory headers
hdr1,hdr2,hdr3 i am trying this code try { String path = "http://x.com/server.xml"; HashMap parameters = new HashMap(); parameters.put("hdr1",this.hdr1); if(mUserLoggedIn){ parameters.put("hdr2",this.hdr2); parameters.put("hdr3",this.hdr3); } // Setup the connection String uri = new String(path); URL url = new URL(uri); URLConnection conn = url.openConnection(); HttpURLConnection httpConnection = (HttpURLConnection)conn; String boundary = "myboundary"; conn.setDoOutput(true); conn.setDoInput(true); conn.setUseCaches(false); conn.setRequestProperty("Connection","Keep-Alive"); conn.setRequestProperty("Content-Type","multipart/form-data; boundary=" + boundary); DataOutputStream wr = new DataOutputStream (conn.getOutputStream()); // Send the normal form data int responseCode = httpConnection.getResponseCode(); Iterator i = parameters.entrySet().iterator(); while (i.hasNext()) { Map.Entry param = (Map.Entry)i.next(); wr.write( ("--" + boundary + "\r\n").getBytes() ); wr.write( ("Content-Disposition: form-data; name=\""+ (String)param.getKey()+"\"\r\n\r\n").getBytes()); wr.write( ((String)param.getValue() + "\r\n").getBytes ()); wr.flush(); } wr.close(); // DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); // DocumentBuilder db = dbf.newDocumentBuilder(); // Document dom = db.parse(conn.getInputStream()); // Element rootElement = dom.getDocumentElement(); responseCode is 400 which seems a header missing error any solution? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---