2013-03-15 3 views
0

저는 Restful Web Service에 연결하고 JSON 응답을 얻고 있습니다.json 응답 안드로이드 오류가있는 Https 게시물 요청

내가 요청을 보내고 JSON 객체의 응답을 처리 할 수 ​​있어요,하지만 문제는 오류받을 수 있습니다 :

Invalid api_key(is a parameter that I send,but I am sure is right). 

당신이 문제의가 있는지 이해하는 데 도움 주실를 내 코드 또는 WEB에서? postParameters.add(new BasicNameValuePair("api_key", "apy_key"));

당신이 주어진 apiKey에 두 번째 피연산자를 교체 :

HttpClient httpClient = new DefaultHttpClient(); 
httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("SSLSocketFactory", SSLSocketFactory.getSocketFactory(), 443)); 
HttpPost request = new HttpPost(); 
request.setHeader("Content-type", "application/json, charset=utf-8"); 
request.setHeader("Accept", "application/json"); 
URI targetUri = new URI(TARGET_URL); 
request.setURI(targetUri); 
List<NameValuePair> postParameters = new ArrayList<NameValuePair>(); 
postParameters.add(new BasicNameValuePair("api_key", "api_key")); 
postParameters.add(new BasicNameValuePair("user[email]", email)); 
postParameters.add(new BasicNameValuePair("user[password]",pwd)); 

Log.i("","EMAIL REQUEST: "+email.toString()); 
Log.i("","PWD REQUEST: "+pwd.toString()); 
HttpEntity postEntity = new UrlEncodedFormEntity(postParameters,"UTF-8"); 
request.setEntity(postEntity); 
Log.i("","Request header "+request.getRequestLine()); 
Log.i("","Request : " +EntityUtils.toString(request.getEntity())); 

httpClient.execute(request, myResponseHandler); 
+0

구성표 생성자는 인수에서 구성표의 값을 사용합니다. 귀하의 경우, "https"가 아닌 "SSLSocketFactory". – njzk2

+0

그런 다음 content-type application/json을 선언하고 있지만 실제로 application/x-www-form-urlencoded – njzk2

+0

을 sendind하면 실행 결과와 관련이없는 것 같습니까? – njzk2

답변

0

당신이 API 키에 expectes에게 실제 값을 해결하고 서비스처럼 보인다.

+0

예 개인 정보 보호를 위해 apy_key를 작성했지만 특정 코드입니다 – user2173922

+0

또한 STATUS LINE을 출력하고 401입니다. 즉, 보내려는 매개 변수에 문제가있을 수 있습니다. – user2173922

관련 문제