How can i retrieve the macro id for Jira Issues macro?
Asked by Vikrant Mandle:

Dear Atlassian Community, I am currently developing a custom Confluence macro to facilitate the transfer of data from user inputs to Jira Issues macro format. My macro successfully retrieves user-defined JQL and issue fields, processes them on the backend, and aims to publish the resulting data within the Jira Issues macro format. However, I am encountering difficulty in locating the essential macro ID required for embedding the data into the Jira Issues macro. As of my research, I have found no accessible API endpoint to retrieve this macro ID programmatically. Could someone from the community kindly provide guidance or suggestions on how to obtain this macro ID effectively? Any insights or alternative approaches to accomplish this task would be greatly appreciated.  
The Jira issues macro format is (i am trying to retrieve id) :  
\<a href="<https://example.atlassian.net/issues/?jql=jqlQuery>" data-card-appearance="block" data-datasource="{id: d8b75300-dfda-4519-b6cd-e49abbd50401 , parameters :{ cloudId : cloudId , jql : jqlQuery }, views :\[{ type : table , properties :{ columns :\[{ key : issuetype },{ key : key },{ key : summary },{ key : assignee },{ key : priority },{ key : status },{ key : updated }\]}}\]}"\><https://example.atlassian.net/issues/?jql=jqlQuery>\</a\>  

<br />

Thank you in advance for your assistance.


Answers:
author: Darryl Lee
body: Hey [@Vikrant Mandle](/t5/user/viewprofilepage/user-id/5453671) - I know you're asking me about Confluence. Bear with me - I will get there eventually...

So [@Sarah Wright](/t5/user/viewprofilepage/user-id/5062422) was asking about using Automation to insert this "macro" into a Jira rich text fields (like Description).

This allows you to insert a nifty table of Jira issues right into ... your Jira issue Description. ***(INCEPTION!!!!)***

![Screenshot 2024-09-20 at 7.37.44?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/348496iE712162158988F5C/image-size/large?v=v2&px=999 "Screenshot 2024-09-20 at 7.37.44?PM.png")

So I'm always up for poking around with Developer tools, and here's what I found.

I this the description below straight out of the API, looking at an issue with an existing table: <https://MYSITE.atlassian.net/rest/api/2/issue/EET-293>

And I tried modifying another issue using Automation's "Advanced Field Editing":
> {   
> "fields": {   
> "description": "Testing\\n\\n\[<https://roku-sandbox-815.atlassian.net/issues/?jql=project%20in%20(EET)%20and%20created%20%3E%20-7d%7Chttps://roku-sandbox-815.atlassian.net/issues/?jql=project%20in%20(EET)%20and%20created%20%3E%20-7d%7Csmart-card>\]"   
> }  
> }

Alas, all I got was a smart card, with an option to make it into a Link, which sure, sombody could click, but we want it to happen... Automagically

![image (29).png](https://community.atlassian.com/t5/image/serverpage/image-id/348497i8DBFE1AE2193C19A/image-size/large?v=v2&px=999 "image (29).png")

So I had to dig DEEPER. And I found this PUT request when I expanded the smart card into a list:
> {  
> "fields": {  
> "description": {  
> "version": 1,  
> "type": "doc",  
> "content": \[  
> {  
> "type": "blockCard",  
> "attrs": {  
> "url": "<https://MYSITE.atlassian.net/issues/?jql=project%20in%20(BUG)%20ORDER%20BY%20created%20DESC>",  
> "datasource": {  
> "id": "**d8b75300-dfda-4519-b6cd-e49abbd50401** ",  
> "parameters": {  
> "cloudId": "MYTENANT",  
> "jql": "project in (BUG) ORDER BY created DESC"  
> },  
> "views": \[  
> {  
> "type": "table",  
> "properties": {  
> "columns": \[  
> {  
> "key": "issuetype"  
> },  
> {  
> "key": "key"  
> },  
> {  
> "key": "summary"  
> },  
> {  
> "key": "assignee"  
> },  
> {  
> "key": "priority"  
> },  
> {  
> "key": "status"  
> },  
> {  
> "key": "updated"  
> }\]}}\]}}}\]}}}

The request was a PUT to **<https://MYSITE.atlassian.net/rest/api/3/issue/BUG-1>**

Does that **"id": "d8b75300-dfda-4519-b6cd-e49abbd50401"**, look familiar? It's the same ID as yours, which is how I found this post!

I believe that is the "ID" for this "macro" in Jira!

This documentation shows how you could update an issue field using data like above:

* [Adding a comment that is stored in a smartvalue (Variable) as an ADF(Atlassian Document Format) using Automation](https://confluence.atlassian.com/jirakb/adding-a-comment-that-is-stored-in-a-smartvalue-variable-as-an-adf-atlassian-document-format-using-automation-1387598043.html)

ANYWAYS. Confluence. Let's take a peek. Yup, ok, I added a Jira Macro table to a page. It published to this endpoint:  
**[https://MYSITE.atlassian.net/wiki/rest/api/content/1108213762/?status=draft\&action=publish](https://MYSITE.atlassian.net/wiki/rest/api/content/1108213762/?status=draft&action=publish)**  
And poking around in the Payload, yup, there's our old friend (with a lot of escaping):  
**\\"datasource\\":{\\"id\\":\\"d8b75300-dfda-4519-b6cd-e49abbd50401\\"**  
So then. That's your "macro" ID. Although it's not really a macro. In Confluence as well, this section is defined as: **\\"type\\":\\"blockCard\\"**  
So. There you go. I mean... it's a start. :-}  
And always remember, the Developer Panel is your friend.


author: Shawn Doyle - ReleaseTEAM
body: View the source of the page that has the macro and hunt through the HTML for the id.


Tags: cloud

confluence-cloud