Problems fetching Custom Content in Forge

Hi there,

I’m having a hard time implementing the lately introduced confluence:customContent Forge module.

Following the documentation, I’ve added a module like this

  confluence:customContent:
    - key: foo
      resource: foo-res
      title: Foo Custom Content
      supportedContainerTypes:
        - space
      supportedChildTypes:
        - attachment
        - comment
      supportedSpacePermissions:
        - read
        - create
        - delete
      indexing: true
      preventDuplicateTitle: true

...

permissions:
  scopes:
    - read:confluence-content.summary
    - write:confluence-content

Now I want to test if the content type is available (assuming to get an empty array). Following the documentation again, I tried to send the following REST API request

  const type = `forge:${appId}:DEVELOPMENT:foo`;
  const resp = await asApp().requestConfluence(route`/wiki/rest/api/content?type=${type}`, {
    headers: {'Accept': 'application/json'},
  });

Which leads to an 501 error saying "com.atlassian.confluence.api.service.exceptions.unchecked.NotImplementedServiceException: Cannot find custom content type : forge:${appId}:DEVELOPMENT:foo"

Any thoughts what might be wrong? Thanks in advance!

1 Like

I encountered the same issue, but thanks to @FabianSiegel1’s instructive CQL search POC for custom content and the verbose error response from the search API, I realized that the content type structure is based on the actual environmentId rather than its name like DEVELOPMENT (note the undefined):

{
    "statusCode": 400,
    "data": {
        "authorized": true,
        "valid": true,
        "errors": [],
        "successful": true
    },
    "message":"com.atlassian.confluence.api.service.exceptions.BadRequestException: Unsupported value for type, 
     got: forge:41e6d8cb-f99c-4ef0-8289-287c29dc7cd0:undefined:foo, 
     expected one of : [
       space, user, page, blogpost, comment, attachment, 
       forge:41e6d8cb-f99c-4ef0-8289-287c29dc7cd0:4a729d16-aa22-4ebb-8696-f71f42711908:foo
    ]"
}

Using the environmentId from useProductContext() as correctly documented above the respectively misleadingly example within Confluence custom content allows to create/update/delete/search custom content implemented with Forge :slight_smile:

2 Likes

@sopel thanks for POC - I somehow missed that… Probs to @FabianSiegel1 !

Comparing the code, I found my mistakes

  • Changing resource to function (and providing it as the example suggests)
  • using the environmentId instead of the environmentType

After these changes it works like a charme!

2 Likes

Hi @ppasler, we’re also just struggling to get the custom content type stuff up and running. When using the POC from @FabianSiegel1 (big thanks!!!) it works, but as soon as we change the container to a space (and nothing else), like for example:

container: {
    id: 262146,   // retrieved via /wiki/rest/api/space/<SPACEKEY>
    type: "space",
},

…we get a rather less informative 400 bad request:

{
  statusCode: 400,
  data: {
    authorized: true,
    valid: false,
    errors: [ [Object] ],
    successful: false
  },
  message: 'com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not create content with type forge:c0c5f358-b5a9-435d-9a83-b1693b511434:ae8b9284-25c4-4d51-91ee-605f02b16bc0:custom'
}

Do you have an idea what could be wrong here? Are you able to create a custom content entity under a space successfully? Any hint would be highly appreciated.

1 Like

For me it worked by only removing the container node (but keeping space).

...
                space: {
                    key: productContext.spaceKey,
                },
-                container: {
-                    id: productContext.contentId,
-                    type: "page",
-                },
                body: {
...
2 Likes

@ppasler you’re the best, that did the trick! Thanks a lot :slight_smile: :+1:

1 Like