Forums

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

Is it possible to get content body with javascript of macros?

Youke XIANG July 9, 2019

Im using this rest api recently

https://<domain>/rest/api/content/12345?expand=body.view

I've tried body.view,  body.storage, body.styled_view and body.export_view.

Non of them will give me javascript of macros. The text in macro will not be shown in the body. That's is not good.

Is it possible to get those javascript for macro? Even separately?

 

 

1 answer

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 12, 2019

Hello Youke,

The endpoint you’re referencing returns the request page ID as JSON content, and as your expanding the body.view it will include the page contents as markup and HTML. Could you share some more insight into what you’re needing from the endpoint? Any JSON output or screenshots you have will be helpful to understand more of what you’re needing.

Regards,
Stephen Sifers

Youke XIANG July 21, 2019

We are try to render some selected Confluence pages to our customised application. But we cannot get a fully interactive macro rendering correctly. We are happy to provide some screenshots for explain the what we want to do, if you are able to PM me.

Like Stephen Sifers likes this
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 25, 2019

Hello Youke,

I'm still not entirely sure which endpoint you're accessing to attempt to get the contents of a Confluence page. If you’re using the GET CONTENT (GET /wiki/rest/api/content) endpoint then you should be able to add the body value which will give you the contents of a Confluence page with the body.

Is this what you’re attempting to access?

Within Community we do not have private messaging, so we'll need to communicate via this platform.

Regards,
Stephen Sifers

Youke XIANG July 25, 2019

Hey Stephen,

 

We're using 'GET wiki/rest/api/content/$id?expand=body.view' to get the content of a Confluence page, it works perfect unless the page contains any macro. It will throw javascript errors once the content be rendered in the HTML.

So we used 'GET wiki/rest/api/content/$contentId/history/$contentVersion/macro/id/$macroId' to fetch content of macro. But the macro will lost its interactive ability. Such as all the link in macro will be transfer the pain text. Also the image will be rendered in some customised HTML tag (<ac:image/>).

I just wish to know if there are anyway to get the macro rendered correctly.

Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 26, 2019

Hello Youke,

Thanks for clarifying and providing additional information. From what I’m understanding now, you’re wanting to take content from Confluence and redisplay said content which includes macros within another application outside of Confluence. From this information, this may not be possible as the macro will not render outside of Confluence itself. More so, the REST API will display the content as either HTML or Markdown. This will not provide a direct translation to Java which you’re looking for.

There may still be hope, I would suggest reviewing the Confluence Java API to see if you’re able to interact with Confluence via this API allow you to create your own application integration directly. More information on this may be found at Java API reference.

Regards,

Stephen Sifers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events