Hello experts,
I’m trying to receive specific properties of a page after it’s been updated. I’ve created the trigger, but I’m experiencing difficulty with the requestConfluence() function, as it appears unresponsive.
Below are the source code of the trigger and the output from the forge tunnel
.
import api, { route } from "@forge/api";
export async function run(event, context) {
if (!event) {
console.log("Invalid event");
} else {
const contentType=event["content"]["type"]
if (contentType!=="page"){
console.log(`Invalid content type '${contentType}'`, JSON.stringify(event, null, 2));
}else{
const contentId=event["content"]["id"]
checkPageProperties(contentId)
}
}
}
async function checkPageProperties(pageId){
const pageUrl = route`/wiki/rest/api/content/${pageId}/property`
console.log(pageUrl)
const response = await api.asUser().requestConfluence(pageUrl, {
headers: {
'Accept': 'application/json'
}
});
console.log(`Response: ${response.status} ${response.statusText}`);
console.log(await response.json());
}
Listening for requests...
invocation: a9dd841348584ba7 index.run
INFO 15:44:04.310 a9dd841348584ba7 ReadonlyRoute { value_: '/wiki/rest/api/content/33192/property' }
As you can see, after printing the URL
, nothing happened, the trigger seems to be terminated silently.