Properties API not working

Has anyone had this issue before?

Instead of using storage, which isn’t accessible outside the app as far as I can see, I’d like to use properties api, which seems like the inverse would be possible.

I’m setting a property and then retrieving it and getting an undefined result?

Ideally I don’t want to be retrieving it straight away, but am just testing at the moment.

Can anyone see what I’m doing wrong?

Properties API

 const config = useConfig();

 const updateStatus = async (newStatus: Status) => {
    await properties.onConfluencePage(context.contentId).set(config.CurrentStatusString, newStatus);
    let status : Status = await properties.onConfluencePage(context.contentId).get(config.CurrentStatusString);
    if(!status)
      console.log("This b aint working");
    else
      console.log(`Status updated: ${JSON.stringify(status)}`);
}

Then I created a useConfig hook, not to be confused with Forge useConfig:

export const useConfig = () : Config => {
    const config : Config = {
        ComplianceWorkflowSettingsString : "ComplianceWorkflowSettings",
        CurrentStatusString : "CurrentStatus",
        StatusHistory : "StatusHistory"
    }
    return config;
}

Then I get this from my logs:

INFO 2021-07-29T13:15:59.909Z … This b aint working

Anyone out there’s assistance would be greatly appreciated :slight_smile:

1 Like

hmm, that is interesting. Have you tried using the REST Api for Content Properties? Maybe this one is working. While we’re at it. I was just wondering what the difference is between these two Apis. Are these “properties.onConfluencePage” methods just convinient helpers for the Rest Api mentioned below? :face_with_monocle:

https://developer.atlassian.com/cloud/confluence/rest/api-group-content-properties/#api-wiki-rest-api-content-id-property-key-put

2 Likes

Thanks @JulianWolf

Using the api from the link you gave me, does what I was looking for :clap:

Based off the “Properties API” documentation, one could only assume, it looks very similar to the api call that you gave me. I’m going to use the api instead for now. It’s quite a bit more code you have to write, as you have to write a call for Get, Create and Update, whereas, if you use the possible helper calls, it would be 2-3 lines max.

1 Like