Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

ScriptRunner. Rest Endpoint feature to fetch Slack payload.

Serj Shcherbakov
Contributor
November 14, 2023

Hey Folks!

I'm trying to set up my own integration between Jira and Slack using the endpoint scriptrunner feature.

 

In Jira I made a listener spritrunner for the approval process. When the assignee changed I send several requests:

 

  1. to slack: to receive the assigne channel based on mail.
  2. to slack: to send a message with buttons and information from the task.

 

Both jsons are working fine.

 

The problem occurs when the button is clicked and the request goes to the spritrunner endpoint and I cannot read the contents of the payload inside the endpoint. the body comes empty. I tried sending requests from the postman, and the body arrived correctly.

 
Custom endpoint is simple, it looks like:

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.json.JsonBuilder
import groovy.transform.BaseScript
import org.codehaus.jackson.map.ObjectMapper
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import groovyx.net.http.ContentType
import javax.servlet.http.HttpServletRequest
import groovy.json.JsonSlurper
import groovy.json.JsonOutput

@BaseScript CustomEndpointDelegate delegate


doSomething(httpMethod: "POST"){ MultivaluedMap queryParams, String body ->
JsonOutput.toJson([data: body])


log.info("Success! ${body}")

return Response.ok(new JsonBuilder([abc: 42]).toString()).build();
}

 

Perhaps is required to specify a special content type format application/x-www-form-urlencoded  in the endpoint to read information from slack, but I don’t know how to do it correctly.

 

Hope yoг help.

3 answers

0 votes
Andris Grinbergs
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
May 13, 2014

I don't know if it helps, but I would try using this plugin, it allows to change pretty much any text in jira.

https://marketplace.atlassian.com/plugins/com.atlassian.translations.jira.inproduct

If that don't help, check(extract) your language file (jira-language-pack-UK.......jar), you may find there old text, replace it with new one.

0 votes
Deleted user
May 13, 2014

I'm also interested in this

0 votes
Rahul Aich [Nagra]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
March 3, 2014

Any update guys....?

Suggest an answer

Log in or Sign up to answer