Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Script for execution

In this sectionpart, you can give a decision to execute REST according to the result of the Groovy script.add a condition for the listener. 

By default, it has only return true statement which means that listener will execute the REST call. However, you can type your script and return true; to execute REST, or return false; not to executeown script in order to programmatically add condition to execute the REST service or not.


Below, there is a sample code on how you can type your own script.snippet for a condition which checks the logged in user should be the reporter of the issue

Code Block
languagegroovy
titleExecute Code
linenumberstrue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser

ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
log.info("current user:" + currentUser.username)
def reporter = issue.reporter.username
log.info("reporter: " + reporter)
return reporter.equals(currentUser.username)

...

REST Service Details

In this sectionpart, REST details (URL, method, headers, body, credential, ..) are filled.

...

  • The endpoint of the REST service. You can type any dynamic parameter here using double curly braces. (e.g. http://mycompany.com/api/book/{{bookId}} assuming bookId is defined in Parameters section which is described below

...

  • Select the Http Method (GET, POST, PUT, DELETE)
  • Define your HTTP header key/value sets in separate lines as described in screen-shot
  • Type JSON request body. You can use dynamic parameters here as well

...

  • Define all your dynamic parameters here. You can add static values as well as the dynamic values of fields/custom fields in the JIRA issue. Here are some sample usages:

...

  • Choose the authorization type. Currently, BASIC Authentication is supported.  If you choose Basic Authorization Type, credential becomes active, and the credentials you defined in the Credentials section are listed.

Headers code example;

Code Block
titleHeaders
linenumberstrue
Accept=application/json

...