Dear all,
I am actually testing the way to send POST request from script runner inside Script console from Jira.
The issue I have is that it says that some variable are not declare from beeing part of the request. Any idea how to solved it ?
Here is sample call I used below :
====> BEGININ CODE SAMPLE
import groovy.json.*
import groovyx.net.*
import groovyx.net.http.*
import static groovy.json.JsonOutput.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
String targetUrl = 'https://login.microsoftonline.com/oauth2/token'
def http = new HTTPBuilder(targetUrl)
http.request(POST) {
requestContentType = URLENC
body = [from: 'fromAddress', to: 'toAddress', subject: 'sub', text: 'random message']
headers.'Authorization' = "Basic " + "api:my_api_key".bytes.encodeBase64().toString()
headers.'Accept' = 'application/json'
response.success = { resp, json ->
return prettyPrint(toJson(json))
}
}
Any idea why bold variable are reported as undefined in script console ?
Thanks for help on how solving
regards