Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a comment for the page version created?

Yagnesh Bhat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2021

I am trying to find the Java API that will add a comment on the "Page History" Page under the comment column. So what I am doing is when something on my macro changes, I force the page update like so:

pageManager.<Page>saveNewVersion(page, page1 -> page1.setBodyContent(content));

As expected the page gets updated with a new version. 

But I want to add a comment in the "Comment" column of the "Page History" page stating something like "The page version was created because the macro content was changed". Please advise if there is any Java API I can use to achieve this.

2 answers

1 accepted

0 votes
Answer accepted
Yagnesh Bhat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2021
pageManager.<Page>saveNewVersion(page, page1 -> {
page1.setBodyContent(content);
page1.setVersionComment("Version created by the plugin");
});
Kishan Sharma
Community Champion
September 8, 2021

Thanks Yagnesh for sharing the solution!

1 vote
Alexis Robert
Community Champion
September 8, 2021

Hi @Yagnesh Bhat  , 

 

not sure if anyone here will be able to give you an answer specifically for the Java API, so I would suggest asking your question in the Atlassian Developer community, you might have more luck here : https://community.developer.atlassian.com/c/confluence/6

 

As far as I know, this is possible with the regular REST API so you should be able to do it with the Java API : 

PUT /wiki/rest/api/content/{content_id}

{
"id": "content_id",
"title": "Page title",
"space": {"key": "SPACEKEY"},
"type": "page",
"body": {
"storage": {
"value": "Page body",
"representation": "storage"
}
},
"version": {
"message": "version comment",
"number": 2
}
}
 

Let me know if this helps, 

 

--Alexis

Yagnesh Bhat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2021

@Alexis Robert , thanks for the reply. I found the way to do it from the Java API itself:

pageManager.<Page>saveNewVersion(page, page1 -> {
page1.setBodyContent(content);
page1.setVersionComment("Version created by the plugin");
});

Converting this to answer and also updating the same answer in the question I asked in Developer community for reference. 

Like Kishan Sharma likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events