Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Call rest api on post function and get 502 error

Hi all,

I have two instances of Jira Server and need integrate them. I've made a groovy script and add it to post function on issue creation step. This script sends rest requests to another Jira to make issue there. But sometimes another Jira has performance issues and answers with 502 error. Problems can last for several minutes (sometimes more). How can I handle this case? Is it a good idea to add a loop to send a request until I get a 200 response? I'm afraid that in this case issue won't be created in first Jira instance for a long time if another instance having problems for a long time

Or may be I can make not a post function script but Listener which listens issue created event and add a loop to send a request until I get a 200 response there? 


2 answers

Hi @Ram Kumar Aravindakshan _Adaptavist_ 

It's a custom post-function on transition.  Script just create new issue in another instance of Jira if some conditions true 

I need to add code only in one instance

And on issue transition fires my script which send request from instance 1 to instance 2 and if in this time instance 2 slows down issue in instance 2 not created. Is it good idea to loop sending request in instance 1 while instance 2 not stops slowing down 

String jkIssueKey = createIssueInJiraJK()

if (jkIssueKey != null){


} else{

   log.warn("Issue not created, comment not added")

}"End of script")
def createIssueInJiraJK(){    

    def jkIssueKey = null

    def currentIssue = issue.key

    def createdIssueKey

    def addressJira = ""

    def user = ''

    def password = ''

    def authString = "${user}:${password}".bytes.encodeBase64().toString()

    def timeout = 120000

    def defaultRequestConfig = RequestConfig.custom()





    def http = new HTTPBuilder("${addressJira}/rest/api/2/issue")



    try {

        http.request(POST, ContentType.JSON) {

            headers.'Authorization' = "Basic ${authString}"

            body = ["fields":[








                "priority": [

                            "id": "2"





            requestContentType = ContentType.JSON

                response.success = { resp, json ->  

                    jkIssueKey = json.key

          "Issue ${jkIssueKey} was created")

                    return jkIssueKey


                response.failure = { resp ->

                    log.warn("response code is: " + resp.status.toString())        



} catch (Exception e) {

    log.warn("Exception : " + e)


0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 28, 2023

Hi @aas

In your description, you mentioned:-

I have two instances of Jira Server and need integrate them. I've made a groovy script and add it to post function on issue creation step.

Are you adding the code in both instances with the required modifications?

Please share your Post-Function code so I can review it and suggest a better solution.

Also, please clarify what Post-Function you use to make the REST request. Is it the ScriptRunner Custom post-function?

I am looking forward to your feedback.

Thank you and Kind regards,

Hi @Ram Kumar Aravindakshan _Adaptavist_ 

I accidentally answered in the wrong place. Look my answer above please

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events