Try this, you'll need to set up your subdomain
, ticketid
, user
and pass
(I've removed all the unnecessary imports as well):
@Grab( 'org.codehaus.groovy.modules.http-builder:http-builder:0.6' )
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.PUT
import static groovyx.net.http.ContentType.JSON
def subdomain = 'woo'
def ticketid = '123'
def authSite = new HTTPBuilder("https://${subdomain}.zendesk.com/api/v2/tickets/${ticketid}.json");
authSite.auth.basic( 'user', 'pass' )
authSite.request( PUT, JSON ) { req ->
body = [ ticket:[ subject: 'xyz' ] ]
response.success = { resp, json ->
println "Success! ${resp.status}"
}
response.failure = { resp ->
println "Request failed with status ${resp.status}"
}
}