Code example for AuthenticationException

		post.addParam(PARAM_LAST_SYNC, String.valueOf(lastSync));
		post.addParam(PARAM_CLIENT_LIST, serverIdJSON);
		HttpResponse response = post.execute();
		if (response.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
			throw new AuthenticationException();
		final ArrayList<RawContact> rawContacts = new ArrayList<RawContact>();
		// Fetch the response contact as JSON object 
		final JSONObject responseJSON = new JSONObject(response.getResponseBody());
		final JSONArray dirtyContacts = responseJSON.getJSONArray(RESPONSE_DATA);
		// Iterate each contact 
		for (int i = 0; i < dirtyContacts.length(); i++) {
			final JSONObject contactJSON = dirtyContacts.getJSONObject(i);
		return rawContacts;
Connect your IDE to all the code out there  Get Codota for Java