Question

I have a service method in grails that was working fine.

It pulls a JSON via a GET request. After moving to prod we had to change the protocol to HTTPS and now I am getting an exception.

Is there anything I have to change to use the HTTPS protocol? I look all over The HTTPBuilder Documentation and I could not find a single reference to using HTTPS. I also could not find a example on Google.

            def reportList = new ArrayList()
        def result
        //TODO Dynamic PatientKey
        def http = new HTTPBuilder( 'https://mydomain/servicename?key=' + key )


        reportList = null
        http.request( GET, JSON ) { req ->

          headers.Accept = 'application/json'


          response.success = { resp, reader ->

            reportList = reader.getAt("patientReports")

          }


        }

    }
    [ reportList : reportList ]
Was it helpful?

Solution 2

This Grails plugin solution works well in a test or local env because Same-Origin Policy will prevent you from implementing a front-end jQuery AJAX call since the domains are different.

In Prod, since HTTPS was used, and since the domains are the same, a jQuery AJAX call works much better then having the logic in the controller and using the REST plugin.

$.getJSON('${YOUR_URL}', function(data){ var yourData = data.yourData; //Operate on data here });

OTHER TIPS

Whats the exception you are getting? please check that SSL certificate is valid for the website. More here.

http://groovy.codehaus.org/modules/http-builder/doc/ssl.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top