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,361,386
Community Members
 
Community Events
168
Community Groups

ScriptRunner (Groovy Script) to create remote link for an issue

I am trying to create remote web link using Groovy Script via ScriptRunner with the following:

post("/rest/api/3/issue/${issue}/remotelink")

   .header('Content-Type','application-json')

   .body(
               [
                   title: 'weblink',
                   url: 'https://a.b.com/'

          ])

    .asString().body

But nothing happens, when I look at the Script Runner log, I saw the following:

2022-08-16 13:48:51.115 INFO - POST /rest/api/3/issue/JIRATEST2-225/remotelink asString Request Duration: 254ms
2022-08-16 13:48:51.116 WARN - POST request to /rest/api/3/issue/JIRATEST2-225/remotelink returned an error code: status: 400 - Bad Request
body: 









<html>

<head>
    <title>Bad Request (400)</title>
    





<!--[if IE]><![endif]-->
<script type="text/javascript" >
    var contextPath = '';
    var DeferScripts = { deferState: 'disabled' };
</script>

 Why it is a bad request and POST body is empty?

1 answer

1 vote

Looking at the documentation of the REST API end-point you're trying to call, it seems to me that your request body contains only 2 fields, but the end-points expects much more details.

See: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-remote-links/#api-rest-api-3-issue-issueidorkey-remotelink-post

When I use RestAPI tool (postman) to call the Jira Cloud API directly, i was able to create the remote link correctly with the following body

{
"object": {
"title": "TestTitle",
"url": "https://a.b.com"
}
}

The API endpoint is: https://xxx.atlassian.net/rest/api/3/issue/{issueId}/remotelink

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

208 views 1 6
Read article

Atlassian Community Events