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?
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.