Get comments from a custom content type via REST

Oliver Wevers February 26, 2018

I have created a custom content type and now I want to use Confluence-REST to assign comments or properties to it. There is always an error that this type is not supported, is there a possibility that REST can use or do I have to build one myself?

2018-02-26 11_27_32-REST API Browser - d.velop serviceportal.png2018-02-26 11_27_10-REST API Browser - d.velop serviceportal.png

1 answer

0 votes
Hasnae
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 20, 2018

Can you double check your implementation of the ```ContentTypeApiSupport``` class

You should have the method ```supportsChildrenOfType``` implemented


@Component("communityApiSupport")
public class CommunityApiSupport implements ContentTypeApiSupport<CustomContentEntityObject> {

private static final String COMMUNITY_TYPE_KEY = "atlassian.confluence.community:community-type";

private final CustomContentManager customContentManager;
private final SpaceManager spaceManager;

@Autowired
public CommunityApiSupport(
@ComponentImport final CustomContentManager customContentManager,
@ComponentImport final SpaceManager spaceManager) {
this.customContentManager = customContentManager;
this.spaceManager = spaceManager;
}

@Override
public ContentType getHandledType() {
return ContentType.valueOf(COMMUNITY_TYPE_KEY);
}

@Override
public boolean supportsChildrenOfType(ContentType contentType) {
return contentType.in(ContentType.ATTACHMENT, ContentType.COMMENT);
}

...
}

 That tells the custom content API that comments are allowed on your custom type, therefore everything works as expected. For a sample implementation please have a look at https://bitbucket.org/viqueen/confluence-community/src/ad754ddc59b08746fa0a37d4122c3aadd924b261/src/main/java/com/atlassian/confluence/community/type/CommunityApiSupport.java?at=master&fileviewer=file-view-default#CommunityApiSupport.java-63

Screen Shot 2018-04-20 at 18.30.03.pngScreen Shot 2018-04-20 at 18.29.23.png

 

Hope this helps

Hasnae R.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events