Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Why getBodyAsString Method doesn't Work After Upgrading from Confluence 5.6.6 to Confluence 5.7.4

Patrice Rompas
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.
July 3, 2015

In API calls, the following declaration doesn't work anymore after upgrading Confluence from 5.6.6 to 5.7.4:

Page thePage = pageManager.getPage(id);
String theContent = thePage.getBodyAsString();

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Patrice Rompas
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.
July 3, 2015

getBodyAsString() method needs to wrapped in transaction.
Lazy loading of page properties like the body content fails when the constructor of the page object and the lazy loaders are not called within the same transaction.

 The following code should work:

final String curVersionBody = transactionTemplate.execute(new TransactionCallback<String>()
{
@Override
public String doInTransaction()
{ return pageManager.getPage(id).getBodyAsString(); }});
TAGS
AUG Leaders

Atlassian Community Events