I am trying to connect to my company database but keep on getting authentication error. This is the code that tries to access the website where the api’s are. These api connect with the database.
DefaultHttpClient httpClient = new DefaultHttpClient();
URL url1 = new URL ("http://www.xxxxxxx.com/");
String encoding = new String(org.apache.commons.codec.binary.Base64.encodeBase64
(org.apache.commons.codec.binary.StringUtils.getBytesUtf8("xx:xxxxxx"))
);
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Authorization", "Basic" + encoding);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
Could it be you are missing a space in your Authorization header?