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();