0
我试图连接到我的公司数据库,但一直在获取身份验证错误。这是试图访问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();