Code example for HttpURLConnection

Methods: addRequestProperty, getResponseCode, setRequestMethod

0
		try { 
			URL serverURL = new URL("http://" + server + ":50080/botrequesthandler");		//throws MalformedURLException
			HttpURLConnection connection = (HttpURLConnection) serverURL.openConnection(); //throws IOException
			 
			//connection.setDoOutput(true); //Set connection for output only 
			connection.setRequestMethod("GET");
			 
			connection.addRequestProperty("Environment-Id", environmentID);
			connection.addRequestProperty("Segment-Id", segmentID);
			 
			Log.v("Result", ""+connection.getResponseCode());
			 
			return true; //success 
		} 
		catch (MalformedURLException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
		} 
		catch (IOException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();