Unable to create JIRA macro using CLI
Asked by Peter Drill:

Hello,

I am using atlassian-cli 3.4.0 to automate a number of functions after a new build is completed. One of these is to create a new blog entry on Confluence that shows the JIRA issues fixed in the latest version.

If I manually create a blog post that contains a JIRA macro with the appropriate JQL everything works fine, however if I try it using the CLI (command below), I get the error message - Unknown macro: "jira"

**C:\\Tools\\atlassian-cli-3.4.0\\confluence.bat --server <https://readysell.atlassian.net/wiki> --user adam --password MYPASSWORD --action addNews --space "RSELL" --title "Release Notes - 8.15.30517.Alpha" --content "\<p\>\<ac:macro ac:name=\&quot;jira\&quot;\>\<ac:parameter ac:name=\&quot;server\&quot;\>JIRA (readysell.atlassian.net)\</ac:parameter\>\<ac:parameter ac:name=\&quot;serverId\&quot;\>ae02c637-0cfd-33d8-a56c-e4b0dc086094\</ac:parameter\>\<ac:parameter ac:name=\&quot;jqlQuery\&quot;\>\<!\[CDATA\[Project = \&quot;RSELL\&quot; AND FixVersion = \&quot;8.15.30517.Alpha\&quot;\]\]\>\</ac:parameter\>\</ac:macro\>\</p\>" --noConvert --labels "release-notes-alpha"**

Any assistance would be appreciated.

Adam


Answers:
author: Bob Swift (personal)
body: Wiki syntax reads easier :), but you can use xhtml as well, just use " instead of **\&quot;**. Use single quotes around the content to avoid escaping the embedded double quotes or just escape them.

comments: author: Peter Drill
body: Hi Bob,

I have tried it using single quotes and unescaped double quotes as follows:

**confluence.bat --server <https://readysell.atlassian.net/wiki> --user adam --password MYPASSWORD --action addNews --space "RSELL" --title "Release Notes - 8.15.30517.Alpha" --content '\<p\>\<ac:macro ac:name="jira"\>\<ac:parameter ac:name="server"\>JIRA (readysell.atlassian.net)\</ac:parameter\>\<ac:parameter ac:name="serverId"\>ae02c637-0cfd-33d8-a56c-e4b0dc086094\</ac:parameter\>\<ac:parameter ac:name="jqlQuery"\>\<!\[CDATA\[Project = "RSELL" AND FixVersion = "8.15.30517.Alpha"\]\]\>\</ac:parameter\>\</ac:macro\>\</p\>' --noConvert --labels "release-notes-alpha"**

Now, when I execute this I get this error message:

**\< was unexpected at this time.**

And nothing is posted.

Adam


author: Bob Swift (personal)
body: Sorry for the confusion, that syntax works on Linux/Mac but not Windows. I had to get my Windows system started to verify. Here is the Windows syntax for escaping this kind of text that will get the action running, although I am unsure about your xhtml macro stuff.

```
atlassian confluence-4.3.0 --title "Release Notes - 8.15.30517.Alpha" --content "<p><ac:macro ac:name=\"jiraissues\"><ac:parameter ac:name=\"server\">JIRA (readysell.atlassian.net)</ac:parameter><ac:parameter ac:name=\"serverId\">ae02c637-0cfd-33d8-a56c-e4b0dc086094</ac:parameter><ac:parameter ac:name=\"jqlQuery\"><![CDATA[Project = \"RSELL\" AND FixVersion = \"8.15.30517.Alpha\"]]></ac:parameter></ac:macro></p>" --noConvert --labels "release-notes-alpha" --action addNews --space experiment
```

```
Blog created: http://xxxx:118/display/EXPERIMENT/2013/05/21/Release+Notes+-+8.15.30517.Alpha with labels: release-notes-alpha. Blog has id: 78938120
```


author: Peter Drill
body: Hi Bob,

Thanks, that did it! Escaping the quotes with a backslash rather than using \&quot; fixed the macro.

Adam


author: jean-baptiste guillot
body: Hi,

Thks a lot Adam and Bob

Jb


Tags: cli

cloud

confluence-cloud

macro