Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Script To call a REST Web service without any 3rd party plugins, any pointers?

Hi I need to call a REST service as part of the buildscript (Gradle) without any 3rd party plugins, how could I use Groovy to do that?

(My first attempt)

repositories {     mavenCentral() }       dependencies {               complie "org.codehaus.groovy.modules.http-builder:http-builder:0.5.2"       }    task hello {     def http = new HTTPBuilder("http://myserver.com:8983/solr/select?q=*&wt=json")     http.auth.basic 'username', 'password'     http.request(GET, JSON ) { req ->     } } 
like image 759
user2599381 Avatar asked Jun 05 '14 11:06

user2599381


1 Answers

Can't you just do

new URL( 'http://username:[email protected]:8983/solr/select?q=*&wt=json' ).text 
like image 195
tim_yates Avatar answered Oct 03 '22 12:10

tim_yates