Hierarchy

  • CommonHttpService
    • ContentBodyService

Constructors

  • Internal

    Create a new instance of the service.

    Parameters

    • getClientInstance: (() => CommonHttpClient)
        • (): CommonHttpClient
        • Returns CommonHttpClient

    Returns ContentBodyService

Methods

  • Converts a content body from one format to another format asynchronously. Returns the asyncId for the asynchronous task.

    Supported conversions:

    • atlas_doc_format: editor, export_view, storage, styled_view, view
    • storage: atlas_doc_format, editor, export_view, styled_view, view
    • editor: storage

    No other conversions are supported at the moment. Once a conversion is completed, it will be available for 5 minutes at the result endpoint.

    Permissions required: If request specifies 'contentIdContext', 'View' permission for the space, and permission to view the content.

    Parameters

    • params: {
          allowCache?: boolean;
          contentBodyCreate: ContentBodyCreate;
          contentIdContext?: string;
          embeddedContentRender?: "current" | "version-at-save";
          expand?: string[];
          spaceKeyContext?: string;
          to: "export_view";
      }
      • OptionalallowCache?: boolean

        Controls whether conversion results are cached and reused for identical requests.

        • false: Each request creates a new conversion task, even if an identical request was made previously.
        • true: Enables caching behavior for identical requests from the same user.
          • If no cached result exists, a new conversion task is created
          • If a cached result exists, the existing task is marked as RERUNNING and will complete with status COMPLETED
          • Returns the same task ID for identical requests, allowing you to retrieve the cached result
      • contentBodyCreate: ContentBodyCreate

        The content body to convert.

      • OptionalcontentIdContext?: string

        The content ID used to find the space for resolving embedded content (page includes, files, and links) in the content body. For example, if the source content contains the link <ac:link><ri:page ri:content-title="Example page" /><ac:link> and the contentIdContext=123 parameter is provided, then the link will be converted to a link to the "Example page" page in the same space that has the content with ID=123. Note, spaceKeyContext will be ignored if this parameter is provided.

      • OptionalembeddedContentRender?: "current" | "version-at-save"

        Mode used for rendering embedded content, like attachments.

        • current renders the embedded content using the latest version.
        • version-at-save renders the embedded content using the version at the time of save.
      • Optionalexpand?: string[]

        A multi-value parameter indicating which properties of the content to expand and populate. Expands are dependent on the to conversion format and may be irrelevant for certain conversions (e.g. macroRenderedOutput is redundant when converting to view format).

        If rendering to view format, and the body content being converted includes arbitrary nested content (such as macros); then it is necessary to include webresource expands in the request. Webresources for content body are the batched JS and CSS dependencies for any nested dynamic content (i.e. macros).

        • embeddedContent returns metadata for nested content (e.g. page included using page include macro)
        • mediaToken returns JWT token for retrieving attachment data from Media API
        • macroRenderedOutput additionally converts body to view format
        • webresource.superbatch.uris.js returns all common JS dependencies as static URLs
        • webresource.superbatch.uris.css returns all common CSS dependencies as static URLs
        • webresource.superbatch.uris.all returns all common dependencies as static URLs
        • webresource.superbatch.tags.all returns all common JS dependencies as html <script> tags
        • webresource.superbatch.tags.css returns all common CSS dependencies as html <style> tags
        • webresource.superbatch.tags.js returns all common dependencies as html <script> and <style> tags
        • webresource.uris.js returns JS dependencies specific to conversion
        • webresource.uris.css returns CSS dependencies specific to conversion
        • webresource.uris.all returns all dependencies specific to conversion
        • webresource.tags.all returns common JS dependencies as html <script> tags
        • webresource.tags.css returns common CSS dependencies as html <style> tags
        • webresource.tags.js returns common dependencies as html <script> and <style> tags
      • OptionalspaceKeyContext?: string

        The space key used for resolving embedded content (page includes, files, and links) in the content body. For example, if the source content contains the link <ac:link><ri:page ri:content-title="Example page" /><ac:link> and the spaceKeyContext=TEST parameter is provided, then the link will be converted to a link to the "Example page" page in the "TEST" space.

      • to: "export_view"

        The name of the target format for the content body.

    Returns Promise<AsyncId>

    Returned if the content is added to the messaging queue for conversion. This id will be available for 5 minutes after the conversion is complete.

    POST /wiki/rest/api/contentbody/convert/async/{to} @scopes-current read:confluence-content.all @scopes-beta read:content.metadata:confluence

  • Returns the content body for the corresponding asyncId of a completed conversion task. If the task is not completed, the task status is returned instead.

    Once a conversion task is completed, the result can be obtained for up to 5 minutes, or until an identical conversion request is made again with the allowCache parameter set to false.

    Permissions required: If request specifies 'contentIdContext', 'View' permission for the space, and permission to view the content.

    Parameters

    • params: {
          id: string;
      }
      • id: string

        The asyncId of the macro task to get the converted body.

    Returns Promise<AsyncContentBody>

    Returned if successfully found an async conversion task associated with the id.

    GET /wiki/rest/api/contentbody/convert/async/{id} @scopes-current read:confluence-content.all @scopes-beta read:content.metadata:confluence

  • Asynchronously converts content bodies from one format to another format in bulk. Use the Content body REST API to get the status of conversion tasks. Note that there is a maximum limit of 10 conversions per request to this endpoint.

    Supported conversions:

    • storage: editor, export_view, styled_view, view
    • editor: storage

    Once a conversion task is completed, it is available for polling for up to 5 minutes.

    Permissions required: 'View' permission for the space, and permission to view the content if the spaceKeyContext or contentIdContext are present.

    Parameters

    Returns Promise<AsyncIdArray>

    Returned if asynchronous tasks are created to convert content bodies. If a conversion task fails to be created, a “FAILED_TO_QUEUE” string will be returned instead of an asyncId.

    POST /wiki/rest/api/contentbody/convert/async/bulk/tasks @scopes-current read:confluence-content.all @scopes-beta read:content.metadata:confluence

  • Returns the content body for the corresponding asyncId of a completed conversion task. If the task is not completed, the task status is returned instead.

    Once a conversion task is completed, the result can be obtained for up to 5 minutes, or until an identical conversion request is made again with the allowCache parameter set to false.

    Note that there is a maximum limit of 50 task results per request to this endpoint.

    Permissions required: Permission to access the Confluence site ('Can use' global permission).

    Parameters

    • params: {
          ids: string[];
      }
      • ids: string[]

        The asyncIds of the conversion tasks.

    Returns Promise<AsyncContentBodyArray>

    Returned if asynchronous conversion tasks are successfully found.

    GET /wiki/rest/api/contentbody/convert/async/bulk/tasks @scopes-current read:confluence-content.all @scopes-beta read:content.metadata:confluence

  • Method to initialize the class. Normally used to set up validation rules.

    Returns void