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

Delete an issue link in CLOUD Scriptrunner with groovy

Zita Bagi
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 Leaders.
August 5, 2021

Dear All,

 

I can link issues in Cloud with Scriptrunner

https://library.adaptavist.com/entity/add-or-update-the-issue-link-for-an-issue-in-jira

but I haven't been able to find a way to remove an issue link.

I tried null here, but it didn't work:

 

def link = post('/rest/api/2/issueLink')
.header('Content-Type', 'application/json')
.body([
type: [ name: linkType ],
outwardIssue: [ key: null], 
inwardIssue: [ key: null] 
])
.asString()

 

Does anyone have any suggesstions?

Thank you!

3 answers

1 accepted

0 votes
Answer accepted
Zita Bagi
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 Leaders.
August 10, 2021

It worked like this:

 def link = delete('/rest/api/2/issueLink/'+linkId)
 .header('Content-Type', 'application/json')
 .asObject(Map)

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-links/#api-rest-api-3-issuelink-linkid-delete

0 votes
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 5, 2021

Hi @Zita Bagi  Insted of POST , use "Delete".

Thanks

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 5, 2021
Like • Zita Bagi likes this
Zita Bagi
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 Leaders.
August 5, 2021

Thank you, I'll try that!

Zita Bagi
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 Leaders.
August 9, 2021

Hi @Vikrant Yadav I tried it and I get this:

2021-08-09 16:25:06.504 ERROR - groovy.lang.MissingMethodException: No signature of method: Script1.DELETE() is applicable for argument types: (String) values: [/rest/api/2/issueLink/25225]

It's like this:

 def link = DELETE('/rest/api/2/issueLink/'+linkId)
.header('Content-Type', 'application/json')
.asString()

Thank you if you can have a look at this!

Zita Bagi
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 Leaders.
August 10, 2021 edited

It worked like this:

 def link = delete('/rest/api/2/issueLink/'+linkId)
 .header('Content-Type', 'application/json')
 .asObject(Map)

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-links/#api-rest-api-3-issuelink-linkid-delete

0 votes
Graham Twine _Slm_
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 Leaders.
August 5, 2021 edited

Have a look at this class from the link you provided.

com.atlassian.jira.issue.link.IssueLinkTypeManager

 


ComponentAccessor.issueLinkManager.removeIssueLinks(issue, currentUser)

 

Zita Bagi
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 Leaders.
August 5, 2021

Thanks, but I wrote CLOUD. Cloud groovy is different form server.

I'm aware of removeIssueLinks on server.

Suggest an answer

Log in or Sign up to answer