Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

REST POST call to external application in Jira workflow postfunction

Edited

Hi,

 

I have project where when workflow transition moves from TODO to IN PROGRESS, i need to send custom field values to external url for validation. i havet ried groovy script using REST API in workflow postfunction where i am trying to pass value but i am getting error.

The response from the REST API should shown in jira screen. how can i make it happen?

 

I am new to groovy scripting and can someone help with restructuring the code

 

import groovy.json.JsonSlurper;
import groovy.json.StreamingJsonBuilder;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue
import org.apache.commons.codec.binary.Base64;

 


def region="CANADA"
def id="121190"
def email="email_id@gmail.com"

 


def body_req = [
"region":region,
"ccid":id,
"email":email

]

def baseURL = "http://local-url:1000/process";

URL url;

url = new URL(baseURL);

URLConnection connection = url.openConnection();
connection.requestMethod = "POST"
connection.doOutput = true
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8")
connection.outputStream.withWriter("UTF-8") { new StreamingJsonBuilder(it, body_req) }
connection.connect();


println("url: " + url);
println("Content:" + connection.getContent())
println("ResponseCode:" + connection.getResponseCode())
println("getResponseMessage:" + connection.getResponseMessage())

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Do you use Jira Cloud with Microsoft Teams?

Hi, Jira users! Do you use Jira alongside Microsoft Teams? We want to hear how you’ve used the power of Jira Cloud and Microsoft Teams (via the Jira Cloud for Microsoft Teams app) to achieve a team...

316 views 1 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you