0
현재 REST 요청을 수행하여 응답 JSON을 얻으려고하고 있지만 문제는 "상태가 200 일 때 : 확인을 클릭 한 다음 JSON 응답을 받지만 상태가 403 일 때 : 금지 된 경우 JSON 응답 받기 ". OK가 아닌 다른 상태 메시지에 :POST 요청 403 금지됨
인터페이스 :
@Rest(rootUrl = "http://something.com", converters = {FormHttpMessageConverter.class, GsonHttpMessageConverter.class})
public interface RestClient {
@Post("/isec/api/user/login")
JsonObject LoginIt(@Field String email, @Field String password, @Field String type);
}
사용법 :
JsonObject p = restClient.LoginIt(emailText.getText().toString(),passwordText.getText().toString(),spinner1.getSelectedItem().toString().toUpperCase());
GsonStr = new Gson().toJson(p);
ShowResults(p);
로그 :
다음은 200에 내 작업 코드E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1
Process: com.jutt.isec, PID: 3463
org.springframework.web.client.HttpClientErrorException: 403 Forbidden
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:88)
at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:585)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:541)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:499)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:447)
at com.jutt.isec.RestClient_.LoginIt(RestClient_.java:41)
at com.jutt.isec.MainActivity.doLogin(MainActivity.java:130)
at com.jutt.isec.MainActivity_.access$201(MainActivity_.java:31)
at com.jutt.isec.MainActivity_$5.execute(MainActivity_.java:159)
at org.androidannotations.api.BackgroundExecutor$Task.run(BackgroundExecutor.java:405)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
어떤 제안이나 해결책이 있습니까? 미리 감사드립니다.
403 번을 금지하면 json 응답이 시작되지 않습니다. 그래서 json으로 처리하려고하지 마십시오. – greenapps
그러면 예외 또는 뭔가를 처리하는 방법, 그렇지 않으면 내 응용 프로그램이 어쨌든 충돌합니다 –
try catch 블록에 전화를 넣으십시오. 그러면 응용 프로그램이 중단되지 않습니다. 응용 프로그램이 충돌하는 경우 LogCat에서 원인을 찾을 수 있습니다. 그래서 어떤 예외가 발생했는지 알 수 있습니다. 어떤 예외가 있는지 알려주십시오. – greenapps