Hi,
I am trying to write a script in Jira Workflow postfunction which sends POST to external server.
Below is my script to send POST request to url(http://test:8000). The below script gives error as
[static type checking] the variable [requestContentType] is undeclared
[static type checking] the variable [response] is undeclared
[static type checking] the variable [resp.status] is undeclared
I am new to groovy script. Could you please help me in understanding why the error occurs and correct way to send POST request to URL?
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.ContentType.*
import groovyx.net.http.ContentType
import static groovyx.net.http.Method.*
import groovy.json.JsonSlurper
import net.sf.json.groovy.JsonSlurper
def http = new HTTPBuilder('http://test:8000/process')
http.request(GET) {
requestContentType = ContentType.JSON
//body = [region: 'USERNAME', password: 'PASSWORD']
response.success = { resp, JSON ->
return JSON
}
response.failure = { resp ->
return "Request failed with status ${resp.status}"
}
}
Regards,
Tamil