Skip to content

Instantly share code, notes, and snippets.

@rdmueller
Created March 28, 2016 21:18
Show Gist options
  • Save rdmueller/6f49ec4f270b04afefc1 to your computer and use it in GitHub Desktop.
Save rdmueller/6f49ec4f270b04afefc1 to your computer and use it in GitHub Desktop.
An example on how to fetch all open issues of a repository with groovy.
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.6' )
import groovyx.net.http.RESTClient
import groovyx.net.http.EncoderRegistry
def github = new RESTClient( 'https://api.github.com/' )
github.encoderRegistry = new EncoderRegistry( charset: 'utf-8' )
def headers = [
'Content-Type':'application/json; charset=utf-8',
'User-Agent':'rdmueller' // replace with your github user name
]
github.handler.failure = { resp, data -> resp.setData(data); return resp }
def res = github.get(path:'repos/rdmueller/grails-filmStrip/issues', query:[:],headers:headers)
res.data.each {
println "${"#${it.number}".padLeft(3)} ${it.state.padRight(6)} ${it.title.take(120)} "
}
""
@rdmueller
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment