0

Can we request a https link using HttpBuilder ?

1 - if yes then is their any specific parameters or properties we need to set while request the data.

2 - if not then can we request same as the normal http link as in the below e.g.

def http = new HTTPBuilder('http://some_link'); 
def resp = http.get(path: '/abcd/efg', query:[login:'login_id', pass: 'password',ttype:'trans_type',prodid:'prod_id'], contentType : XML, headers : [Accept : 'application/xml'] )
praveen2609
  • 223
  • 1
  • 6
  • 15
  • Did you try it? A quick search for `HTTPBuilder` and `https` returns [this page](http://groovy.codehaus.org/modules/http-builder/doc/ssl.html) that says it should just work...and has documentation for whn it doesn't work... – tim_yates Jul 19 '12 at 12:43

1 Answers1

1

Just tried it, and it does work as it says in the docs...

@Grab( 'org.ccil.cowan.tagsoup:tagsoup:1.2' )
@Grab( 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.2' )
import org.ccil.cowan.tagsoup.Parser
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*

// Using an https url
new HTTPBuilder( 'https://twitter.com' ).with {
  // Get from the given path as TEXT
  get( path:'/tim_yates', contentType:TEXT ) { resp, reader ->
    // Pass the html through tagsoup and generate a parser
    new XmlParser( new Parser() ).parseText( reader.text ).with {
      // print the title text from inside the head section
      println head.title.text()
    }
  }
}
tim_yates
  • 167,322
  • 27
  • 342
  • 338
  • im not able to deploy the war file in jboss after using the httpBuilder rest plugin in grails as it was not able to call the http/https link it gives the exception of that url – praveen2609 Aug 03 '12 at 09:53
  • @praveen2609 What exception? What url? You probably should have mentioned grails and the rest plugin in your question? Maybe time to start a new question with the problems you are now having? – tim_yates Aug 03 '12 at 09:56