It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

getting error while creating confluence page from post function in jira

Hi Support,

I have a script which creates a page in confluence from jira ,page is creating successfully .but the created is not linked back in jira.

I mean in jira it is not showing the created page inside the "metioned in" Issuelink.

In post function I am getting the below error :

2019-09-24 17:41:25,015 ERROR [runner.ScriptFieldPreviewRunner]: ************************************************************************************* 2019-09-24 17:41:25,015 ERROR [runner.ScriptFieldPreviewRunner]: Script field preview failed for field that has not yet been created java.lang.IllegalArgumentException: Text must not be null or empty at Script333$1.handle(Script333.groovy:128) at com.atlassian.applinks.oauth.auth.OAuthResponseHandler.handle( at$1.handle( at$1.handle( at$2.handle( at at at at com.atlassian.applinks.core.auth.ApplicationLinkRequestAdaptor.execute( at com.atlassian.applinks.oauth.auth.OAuthRequest.execute( at$execute$ Source) at 

2 answers

1 accepted

0 votes
Answer accepted

you are using a custom REST point created with scriptrunner (/rest/scriptrunner/latest/custom/createpagefromtitle), right?

not knowing that code i can't know what does that REST point do. That could be the place to addthe link creation

or, if you can retrieve the confluence page after its creation maybe you could create the link in that moment.

To do that, the code is something like this:

IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager();
issueLinkManager.createIssueLink(issue.getId(), confluenceObjectId , 10400, 1, user)

where confluenceObjectId should be either the url of the created page or the Id of that object (i don't know) and 10400 is the code of the link type

this is the table:

10000Blocksis blocked byblocks 
10001Clonersis cloned byclones 
10002Duplicateis duplicated byduplicates 
10003Relatesrelates torelates to 
10200Epic-Story Linkhas Epicis Epic ofjira_gh_epic_story
10300Gantt End to Starthas to be done afterhas to be done before 
10301Gantt Start to Starthas to be started together withhas to be started together with 
10302Gantt End to Endhas to be finished together withhas to be finished together with 
10303Gantt Start to Endstart is earliest end ofearliest end is start of 
10400ComplementsIs complemented byComplements 
10500Problem/Incidentis caused bycausesservicedesk_automation_default_linktype

sorry i can't help more

Hi @fran garcia gomera 

Thanks for the replay.




Share the script code, pal

import com.atlassian.applinks.api.ApplicationLink
import com.atlassian.applinks.api.ApplicationLinkService
import com.atlassian.applinks.api.application.confluence.ConfluenceApplicationType
import com.atlassian.sal.api.component.ComponentLocator
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import groovy.xml.MarkupBuilder
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.MutableIssue
import groovy.xml.MarkupBuilder

def ApplicationLink getPrimaryConfluenceLink() {
def applicationLinkService = ComponentLocator.getComponent(ApplicationLinkService.class)
final ApplicationLink conflLink = applicationLinkService.getPrimaryApplicationLink(ConfluenceApplicationType.class)
HashSet<String> typecomponentset = new HashSet();
HashSet<String> typeflowset = new HashSet();
def confluenceLink = getPrimaryConfluenceLink()
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
def writer1 = new StringWriter()
def xml1 = new MarkupBuilder(writer1)
assert confluenceLink
CustomFieldManager customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.getIssueManager()
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def searchService = ComponentAccessor.getComponent(SearchService)
def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()
HashSet batchset = new HashSet();
HashSet interfaceset = new HashSet();
def impcomponent = customFieldManager.getCustomFieldObjectByName("Impacted Technical Components")
def impcomponentvalues = issue.getCustomFieldValue(impcomponent)
impcomponentvalues.each { impcomponentvalue ->
Issue issue = impcomponentvalue as MutableIssue
if(issue.getIssueType().name == "Component") {
def typeofcomponent = impcomponentvalue.toString()
MutableIssue childissue = ComponentAccessor.getIssueManager().getIssueObject(typeofcomponent)
def cField = customFieldManager.getCustomFieldObjectByName("Type of Component")
def val = childissue.getCustomFieldValue(cField).toString()
else if(issue.getIssueType().name == "Flow") {
def typeofcomponent = impcomponentvalue.toString()
MutableIssue childissue = ComponentAccessor.getIssueManager().getIssueObject(typeofcomponent)
def cField = customFieldManager.getCustomFieldObjectByName("Type of Flow")
def val = childissue.getCustomFieldValue(cField).toString()
else {"other technical component")
def query = jqlQueryParser.parseQuery("project = DD AND \"Type of Impacted Technical Component\" = Batch")
def search =, query, PagerFilter.getUnlimitedFilter())
search.getIssues().each { documentIssue ->
def dod = issueManager.getIssueObject(
def query1 = jqlQueryParser.parseQuery("project = DD AND \"Type of Impacted Technical Component\" = Interface")
def search1 =, query1, PagerFilter.getUnlimitedFilter())
search1.getIssues().each { documentIssue1 ->
def dod1 = issueManager.getIssueObject(

int i = 0;
batchset.each { e ->
int j = i + 0 ;
interfaceset.each { e ->
def params = [
title: "${issue.key}" + " : " + "${issue.summary}",
tamplateid : 15859716 ,
key : issue.key ,
summary : issue.summary ,
batchset : writer.toString() ,
interfaceset : writer1.toString()

def authenticatedRequestFactory = confluenceLink.createImpersonatingAuthenticatedRequestFactory()
.createRequest(Request.MethodType.POST, "/rest/scriptrunner/latest/custom/createpagefromtitle")
.addHeader("Content-Type", "application/json")
.setRequestBody(new JsonBuilder(params).toString())
.execute(new ResponseHandler<Response>() {
void handle(Response response) throws ResponseException {
if(response.statusCode != HttpURLConnection.HTTP_OK) {
throw new Exception(response.getResponseBodyAsString())
else {
def webUrl = new JsonSlurper().parseText(response.responseBodyAsString)["_links"]["webui"] // In this line it is showing the error 

The Application linking between Jira and confluence is as below


Hi @fran garcia gomera 

is there any way to resolve this ?

Thanks & Regards


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Introducing new features for Jira Software Cloud's roadmap

Hi Atlassian community, A few months ago, we offered a sneak peak of the new hierarchy view on the roadmap. Thank you for all the feedback (and excitement) and for helping us shape the direction of...

22,891 views 101 74
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you