Hi! I would like to trigger a REST API call every time a Confluence page is loaded. In particular, I'd like to use Atlassian Forge to identify which macros are present on a given page. I'm using the `/wiki/rest/api/content/${contentId}?expand=body.storage` call to just get the HTML contents of the page, but I'm happy to consider another API call if a more fitting one exists.
However, when I make this call, it just... never returns. It doesn't throw an exception, it doesn't quit, it just gives up. I've tried a number of modifications and debugging, but nothing seems to change the result. Why might this be, and how can I fix it?
Here's my code (src/index.js):
import api, { route } from "@forge/api";
const getPageContent = async (contentId) => {
console.log("Debug 1");
const response = await api
.asApp()
.requestConfluence(
route`/wiki/rest/api/content/${contentId}?expand=body.storage`
);
console.log("Debug 2");
const data = await response.json();
return data;
};
export async function run(event, _context) {
const contentId = event?.content?.id;
if (contentId) {
console.log(contentId);
getPageContent(contentId);
}
}
In particular, running this results in the console output: ${contentId} and "Debug 1", and nothing more.
Here's the manifest:
modules:
trigger:
- key: hello-world
function: main
events:
- avi:confluence:viewed:page
function:
- key: main
handler: index.run
app:
id: ari:cloud:ecosystem::app/uuiduuid-uuid-uuid-uuid-uuiduuiduuid
permissions:
scopes:
- read:confluence-content.summary
- read:confluence-content.all
- read:content-details:confluence
- read:page:confluence
export async function run(event, _context) {
const contentId = event?.content?.id;
if (contentId) {
console.log(contentId);
const pageContent = await getPageContent(contentId);
console.log(pageContent);
return pageContent;
}
}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.