Get content with ContentService fails

Hi,
I want to store a JsonContentProperty with a page. In order to use the corresponding builder, I need the content object of the page. I am using

Content pageContent = contentService.find().withId(page.getContentEntityObject().getContentId()).fetchOneOrNull();

The page definitely exists, but pageContent is nevertheless null. I have no clue why! Any tip?

Thanks
Tuelle

Hi @ttwellmann,

This looks similar to this post. There’s a sample code in the comments and a suggested approach when injecting contentService.

If I assumed incorrectly and the link is not relevant, kindly post your class and the error you are getting. Thanks.

Cheers,
Ian

Hello,

Using ContentService from the Java API when a page does not exist throws a null pointer exception:

contentService.find().withSpace(space).withTitle(title).fetchOrNull()

java.lang.NullPointerException
	at com.atlassian.confluence.api.impl.service.content.typebinding.AttachmentContentTypeApiSupport.getAttachments(AttachmentContentTypeApiSupport.java:98)

Is this a bug or am I doing something wrong ?

Thanks,

Gorka.