Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Rest API get jira macro content

Vaclav Vlcek
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!
August 31, 2021

Hi, 

I am trying to get a Confluence page content by using REST Api. It works, however, I am not able to get content of the Jira Macros that are part of the page.

I am using `node-fetch`

Something like:

 

fetch(
{
   method: "GET",
   headers: {
   Accept: "text/html",
   Authorization: "Basic abcd123456",
},
})
.then((response) => {
return response.text();
})
.then((text) => {
console.log(text)
I see the complete html content, but not the embedded content from embedded Jira issues.
Thank you for any hint!
Vaclav 

1 answer

0 votes
Neil Mansilla
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 2, 2021

Hi @Vaclav Vlcek and welcome to the community. There are a couple of things you can try. First, on your GET content method, try adding the following query parameter:

?expand=body.storage

In the response payload you'll see a body.storage.value which will contain page contents with generated macro output. If you want to peel off a specific macro and fetch that content, you can use the Get Macro Body by Macro ID (docs linkk) API method. With that method, you'd pass arguments like this:

/wiki/rest/api/content/{contentId}/history/{versionOfPage}/macro/id/{macroId}

and you'll get back a payload that includes generated macro data just for that single macro. 

Give those a try to see if you're getting what you need. Good luck!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events