You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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;
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.