Announcement Announcement Module
Collapse
No announcement yet.
HTTP GET failing on android 2.3.3 and works on 4.1.2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTP GET failing on android 2.3.3 and works on 4.1.2

    Hi all,

    I am using retstemplate to make a webservice call to get json data from the server here is my code below
    // Set the Accept header for "application/json"
    Code:
    HttpHeaders requestHeaders = getHttpHeaders();
    
                            // Populate the headers in an HttpEntity object to use for the
                            // request
                            HttpEntity<?> requestEntity = new HttpEntity<Object>(requestHeaders);
    
                            // Create a new RestTemplate instance
                            RestTemplate restTemplate = new RestTemplate();
                            restTemplate.getMessageConverters().add(
                                            new MappingJacksonHttpMessageConverter());
                            // Perform the HTTP GET request
                            ResponseEntity<PatientUnitAddress> responseEntity = restTemplate.exchange(url,
                                            HttpMethod.GET, requestEntity, PatientUnitAddress.class);
    THis code works on android 4.0.1 but fails on 2.3.3. Is there any thing that needs to be added to header or do we need to encode the url in order for it to work in 2.3.3.

    Thanks

  • #2
    Hi, several of the sample apps make very similar requests and work across those two versions. Can you provide any errors or stack traces? Thanks!

    Comment


    • #3
      Hi Roy thanks for your quick reply. Below is the stack trace i get on 2.3.3. And also could it be an ssl(https) issue?
      Code:
      W/RestTemplate(10844): GET request for "https://beta.mylilah.com/api/Patients/69106a37-b5b4-46ce-b0fc-0c4655c92762/PatientUnitAddress" resulted in 400 (Bad Request); invoking error handler
      E/Lilah Patient Application Webservice call(10844): 400 Bad Request
      E/Lilah Patient Application Webservice call(10844): org.springframework.web.client.HttpClientErrorException: 400 Bad Request
      E/Lilah Patient Application Webservice call(10844):     at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76)
      E/Lilah Patient Application Webservice call(10844):     at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:524)
      E/Lilah Patient Application Webservice call(10844):     at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:481)
      E/Lilah Patient Application Webservice call(10844):     at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:439)
      E/Lilah Patient Application Webservice call(10844):     at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:415)
      E/Lilah Patient Application Webservice call(10844):     at com.mylilah.utils.WebServiceUtils.GetUnitAdderss(WebServiceUtils.java:470)
      E/Lilah Patient Application Webservice call(10844):     at com.mylilah.controller.LoginController$DownloadPatientsTask.VerifyBluetoothAddress(LoginController.java:189)
      E/Lilah Patient Application Webservice call(10844):     at com.mylilah.controller.LoginController$DownloadPatientsTask.doInBackground(LoginController.java:143)
      E/Lilah Patient Application Webservice call(10844):     at com.mylilah.controller.LoginController$DownloadPatientsTask.doInBackground(LoginController.java:130)
      E/Lilah Patient Application Webservice call(10844):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
      E/Lilah Patient Application Webservice call(10844):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
      E/Lilah Patient Application Webservice call(10844):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      E/Lilah Patient Application Webservice call(10844):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
      E/Lilah Patient Application Webservice call(10844):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
      E/Lilah Patient Application Webservice call(10844):     at java.lang.Thread.run(Thread.java:1019)
      W/WindowManager( 4217): Window Window{40560900 com.mylilah/com.mylilah.controller.LoginController paused=false} destroyed surface Surface(name=com.mylilah/com.mylilah.controller.LoginController, identity=-1, mNativeSurface=0), session Session{40ca59f0 uid 10109}

      Comment


      • #4
        Originally posted by Roy Clarkson View Post
        Hi, several of the sample apps make very similar requests and work across those two versions. Can you provide any errors or stack traces? Thanks!
        Hi Roy thanks for your quick reply. Below is the stack trace i get on 2.3.3. And also could it be an ssl(https) issue?
        Code:
        W/RestTemplate(10844): GET request for "https://beta.mylilah.com/api/Patients/69106a37-b5b4-46ce-b0fc-0c4655c92762/PatientUnitAddress" resulted in 400 (Bad Request); invoking error handler
        E/Lilah Patient Application Webservice call(10844): 400 Bad Request
        E/Lilah Patient Application Webservice call(10844): org.springframework.web.client.HttpClientErrorException: 400 Bad Request
        E/Lilah Patient Application Webservice call(10844):     at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76)
        E/Lilah Patient Application Webservice call(10844):     at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:524)
        E/Lilah Patient Application Webservice call(10844):     at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:481)
        E/Lilah Patient Application Webservice call(10844):     at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:439)
        E/Lilah Patient Application Webservice call(10844):     at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:415)
        E/Lilah Patient Application Webservice call(10844):     at com.mylilah.utils.WebServiceUtils.GetUnitAdderss(WebServiceUtils.java:470)
        E/Lilah Patient Application Webservice call(10844):     at com.mylilah.controller.LoginController$DownloadPatientsTask.VerifyBluetoothAddress(LoginController.java:189)
        E/Lilah Patient Application Webservice call(10844):     at com.mylilah.controller.LoginController$DownloadPatientsTask.doInBackground(LoginController.java:143)
        E/Lilah Patient Application Webservice call(10844):     at com.mylilah.controller.LoginController$DownloadPatientsTask.doInBackground(LoginController.java:130)
        E/Lilah Patient Application Webservice call(10844):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
        E/Lilah Patient Application Webservice call(10844):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
        E/Lilah Patient Application Webservice call(10844):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        E/Lilah Patient Application Webservice call(10844):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
        E/Lilah Patient Application Webservice call(10844):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
        E/Lilah Patient Application Webservice call(10844):     at java.lang.Thread.run(Thread.java:1019)
        W/WindowManager( 4217): Window Window{40560900 com.mylilah/com.mylilah.controller.LoginController paused=false} destroyed surface Surface(name=com.mylilah/com.mylilah.controller.LoginController, identity=-1, mNativeSurface=0), session Session{40ca59f0 uid 10109}

        Comment

        Working...
        X