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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,462,323
Community Members
 
Community Events
176
Community Groups

how to check get content of web service using script runner

post data.png

1 answer

Thank You now I am getting content.

How I can check my data is sent or not using web service?

What do you mean? You sent data from Jira right? You can log it in. Then you have the web service, which receives your data. You should check if your data has been sent or not in the log of this web service.

I am doing  integration bet Jira and Polarion using web service.

I am using below code but I am not able to update jira id in polarion.

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.ModifiedValue;
import com.atlassian.jira.issue.MutableIssue
import org.apache.commons.codec.binary.Base64;
import java.net.*
import java.io.*;
import org.apache.log4j.Logger
import org.apache.commons.codec.binary.Base64;
import com.atlassian.jira.plugin.webfragment.model.JiraHelper;
import javax.ws.rs.core.Response
import groovy.json.JsonBuilder
import java.util.Scanner;


def myLog = Logger.getLogger("com.onresolve.jira.groovy")
myLog.info("Hello kunti from Jira")

def user = "admin";
def password = "admin";
def issueID = "APS-425";
def issueStatus = "";
def getModifiedFields = "";
def uname = "admin";
def pwd = "admin";

//IssueManager issueManager = ComponentManager.getInstance().getIssueManager();
// //MutableIssue Issue = issueManager.getIssueObject("DEMO-467");
//MutableIssue Issue = issue;

//issueID = Issue.getKey();

//issueStatus = Issue.getStatus()
//getModifiedFields =Issue.getAssignee()
myLog.info ("issueID== " + issueID)
//myLog.info ("issueStatus== " + ComponentAccessor.getIssueManager().getIssueObject(issue.getKey()).getStatus())
//myLog.info ("getAssignee== " + getModifiedFields)
//def issueType = Issue.issueTypeObject.name;
def textToTranslate = "";
def targetLanguage = "";
def originalLanguage ="";
def languagesCodes = [
English:"EN",
Spanish:"ES",
Franch:"FR",
German:"DE",
Polish:"PL",
Russian :"RU",
Japanese:"JP",
Portugese:"PT",
Italian:"IT",
Dutch:"NL",
Turkish:"TR",
Czech:"CZ",
]
textToTranslate = "text to translate"
//targetLanguage = Issue.getCustomFieldValue(targetLanguageObject);

def body_req = [
"user": user,
"password":password,
"jiraid":issueID,
"route":"/resources/text",
//"targetLang":languagesCodes[targetLanguage],
"reqText":textToTranslate
]

def baseURL = "http://inchnsirplmvma1.india.tcs.com:7002/polarion/#/project/APTIV/workitems/softwareReq/APTIV-1273";
URL url;
url = new URL(baseURL);
String authStr = uname + ":" + pwd;
try{
HttpURLConnection connection =(HttpURLConnection) url.openConnection();
connection.requestMethod = "POST"
connection.doOutput = true
connection.setDoInput(true);
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8")
connection.setRequestProperty("Accept", "application/ocsp-response");
connection.outputStream.withWriter("UTF-8") { new StreamingJsonBuilder(it, body_req) }
connection.connect();

myLog.info("url: " + url);
myLog.info("ResponseCode 1= "+ connection.getContent())

String data = "";
InputStream iStream =(InputStream) connection.getContent();
BufferedReader br = new BufferedReader(new InputStreamReader(iStream, "utf8"));
StringBuffer sb = new StringBuffer();
String line = "";

while ((line = br.readLine()) != null) {
sb.append(line);
}

data = sb.toString();
System.out.println(data);
// myLog.info("Data 1= "+ data)
myLog.info("ResponseCode 2= "+connection.getResponseCode())
myLog.info("ResponseCode 3= "+connection.getResponseMessage())
// myLog.info(Response.ok(new JsonBuilder([abc: 42]).toString()).build())
}
catch(IOException e)
{
myLog.info(e)
}
myLog.info("end")

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events