I want call web service on workflow trigger (To Do to in progress)
So I am expecting any simple example to call web service using script runner(Custom script post-function)
If it is a RESTful service, then you can read the following thread:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Change
IssueManager issueManager = ComponentManager.getInstance().getIssueManager();
to
IssueManager issueManager = ComponentAccessor.getIssueManager();
and import com.atlassian.jira.component.ComponentAccessor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexey Matveev COMMUNITY CHAMPION
I am trying to execute below code using script runner but I am getting error
can not find http.client.addRequestInterceptor method.
Could you please help me ASAP.
import groovyx.net.http.RESTClient
import org.apache.http.HttpRequest
//import org.apache.http.client
import org.apache.http.HttpRequestInterceptor
import org.apache.http.protocol.HttpContext;
import org.apache.http.HttpRequestInterceptor;
import groovy.json.JsonSlurper;
import com.atlassian.jira.component.ComponentAccessor
import groovyx.net.http.Method
def constantsManager = ComponentAccessor.getConstantsManager()
def bugId = constantsManager.allIssueTypeObjects.findByName("Bug").id
def RESTClient http
def baseUrl = "http://localhost:8080/jira/"
http = new RESTClient(baseUrl)
http.client.addRequestInterceptor(new HttpRequestInterceptor() {
void process(HttpRequest httpRequest, HttpContext httpContext) {
httpRequest.addHeader('Authorization', 'Basic ' + 'admin:admin'.bytes.encodeBase64().toString())
}
})
def issue = http.request(POST, JSON) {
uri.path = '/jira/rest/api/2/issue'
body = [
fields: [
project: [
key: "JRA"
],
summary: "test issue for rest api",
issuetype: [
id: bugId
],
reporter: [
name: "admin"
]
]
]
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is exactly the error? Maybe you passed wrong parameters to the method?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try to execute it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am trying to execute but I am getting below error
groovy.lang.MissingPropertyException: No such property: POST for class: Script198 at Script198.run(Script198.groovy:32)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.