Hi Team,
For linking jira issue, i tried the below java code and below JSON. but it’s giving me below error, can any one please help on this. I do not have any access issue on jira url, i am able to update other thing using rest API by my using java code, but facing issue in linking the Jira ticket.
Used BELOW Json for LINKING -
…
“update”:{
“issuelinks”:[
{
“add”:{
“type”:{
“name”:“Blocks”,
“inward”:“is blocked by”,
“outward”:“blocks”
},
“outwardIssue”:{
“key”:“TEST-1”
}
}
}
]
}
…
Error - {“errorMessages”:[“Can not instantiate value of type [simple type, class com.atlassian.jira.rest.v2.issue.IssueUpdateBean] from JSON String; no single-String constructor/factory method”]}
Below is the my java code for linking jira issue.
…
CloseableHttpResponse response = null;
CloseableHttpClient httpclient = HttpClients.createDefault();
StringBuffer sb = new StringBuffer();
sb.append("“update”:");
sb.append("{“issuelinks”:[{" add":{“type”:{“name”:“Relates”,");
sb.append("“inward”:“relates to”,");
sb.append("“outward”:“relates to”},");
sb.append("\"outwardIssue\": {\"key\":\"" +oldkey + "\"}}}]}");
HttpPut request = new HttpPut(jiraurl + “/rest/api/” + version
+ “/issue/”+issueid);
StringEntity params = new StringEntity(sb.toString(),"UTF-8");
request.setEntity(params);
request.setHeader("X-Atlassian-Token", "nocheck");
request.setHeader("Authorization", "Basic "
+ jira_attachment_authentication);
request.setHeader("content-type", "application/json");
request.setHeader("Accept", "application/json");
request.setHeader("Charset", "UTF-8");
try {
response = httpclient.execute(request);
log.info("response=" + response);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
result = HttpRequest.convertStreamToString(instream);
…