我正在尝试连接到我的公司数据库,但不断收到身份验证错误。这是尝试访问 api 所在网站的代码。这些 api 与数据库连接。
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();