How can i retrieve the macro id for Jira Issues macro?

Vikrant Mandle
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 14, 2024

 

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>


 

Thank you in advance for your assistance.

2 answers

2 votes
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 20, 2024

Hey @Vikrant Mandle - I know you're asking me about Confluence. Bear with me - I will get there eventually...

So @Sarah Wright 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

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

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:

ANYWAYS. Confluence. Let's take a peek. Yup, ok, I added a Jira Macro table to a page. It published to this endpoint:

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. 
0 votes
Shawn Doyle - ReleaseTEAM
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 14, 2024

View the source of the page that has the macro and hunt through the HTML for the id.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events