Injecting a Jira link macro into a Confluence page

I’m trying to automatically inject a Jira macro inside a Confluence page upon creation of the page. The idea is that a Jira issue is automatically created when the page is created, and then a link is shown in the page.

The way I’m trying to do this is by having the macro code in the page template, as it normally ends up looking in the Confluence Storage Format of the page, which is something like this:

  <ac:structured-macro ac:macro-id="98f7e2d8-9d2b-4a36-b36c-c5ca485b3487" ac:name="jira" ac:schema-version="1">
  <ac:parameter ac:name="server">Jira</ac:parameter>
  <ac:parameter ac:name="columns">key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter>
  <ac:parameter ac:name="serverId">3c3fb4ad-46e5-3340-975c-afc4d2c296c8</ac:parameter>
  <ac:parameter ac:name="key">%{issueKey}</ac:parameter>

and then substituting the %{issueKey} with the key of the Jira issue once the page and the issue are created.

The problem I’m having is that once this is done, I get an error in the page saying:

Error rendering macro 'jira'

java.lang.RuntimeException: com.atlassian.confluence.content.render.xhtml.XhtmlException: java.lang.IllegalArgumentException: Title must not be null or empty.

Funny thing is that, if I go and edit the page and click on “Preview”, the macro shows correctly.

Any ideas why this might be happening? I know it’s not a very orthodox approach, but it should be working.

Thank you.