I am calling a REST Endpoint utilizing HTTPBuilder. I thought I had a pretty solid example from this post.
I can successfully call the REST Endpoint from Postman with Basic authentication.
However, I am getting a couple of errors in the script console.
The request object should be resolved from the http object is my understanding, but no addHeaders() method appears in the code completion.
CODE
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
import groovyx.net.http.ContentType
import static groovyx.net.http.Method.*
def http = new HTTPBuilder('https://<host>/rest/scriptrunner/latest/custom/getLicenseStat')
http.headers = [Accept: 'application/json', charset: 'UTF-8']
def authString = "<acct>:<pass>".getBytes().encodeBase64().toString();
http.request(POST, ContentType.JSON) {
requestContentType = ContentType.JSON
request.addHeader("authorization: Basic ${authString}", "ContentType: application/json")
body = [user: '<username>']
response.success = { resp, JSON ->
return JSON
}
}