Need to add content, instead of updating the whole page while using API

Cihat KARAPINAR August 8, 2022

Hi All,

I got a script output that needs to be uploaded on a page in my confluence space, once in a day. But every time it deletes the previous data. Is it possible to add insted of update.

 

Best regards.

 

1 answer

0 votes
Andrea August 10, 2022

@Cihat KARAPINAR  could you please give a bit more information and/or show what you are coding right now to get this unwanted result? It is hard to say why it is not working without knowing what / how you are doing it.

tnx

Cihat KARAPINAR August 10, 2022

Hi Andrea,

 

I have a powershell script. It returns a list of users and details from a specifig group. The script is running once in a day and the result can be zero or multiple lines. When script result is not null it calls a function. This function invoke a API call. In this API I can update my page but every update I lost my old data. I need to add lines and keep existing data.

 

Best regards.

Cihat KARAPINAR August 10, 2022

example BODY for API

 

{
    "id""46596419",
    "type""page",
    "title""testapiburada",
    "space": {
        "key""SY"
    },
    "body": {
        "storage": {
            "value""<p>{variable's from script.}</p>",
            "representation""storage"
        }
    },
    "version": {
        "number"10
    }
}
Andrea August 10, 2022

 

you ARE using the AtlassianAPI, aren't you? you would have to call append_page() or prepend_page() to insert new content after/before the existing one.

 

If you are directly using post() you'll have to first extract the existing body, then concatenate old body and your new addition before you can post the complete content.

AltlassianConfluenceAPI really makes it much easier.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events