Is it possible to get content body with javascript of macros?
Asked by Youke XIANG:

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?


Answers:
author: Stephen Sifers
body: 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

comments: author: Youke XIANG
body: 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.


author: Stephen Sifers
body: 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](https://developer.atlassian.com/cloud/confluence/rest/#api-content-get)) 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


author: Youke XIANG
body: 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.


author: Stephen Sifers
body: 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](https://developer.atlassian.com/server/confluence/java-api-reference/).

Regards,

Stephen Sifers


Tags: atl-adm