2012-08-07 2 views
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(); 

답변

0

권한 부여 헤더에 공백이 누락 되었습니까?

httpPost.setHeader("Authorization", "Basic " + encoding);