0

Get asynchronously converted content body from the id or the current status of the task.

by
Published Oct 17, 2025

Returns the asynchronous content body for the corresponding id if the task is complete or returns the status of the task. After the task is completed, the result can be obtained for 5 minutes, or until an identical conversion request is made again, with allowCache query param set to false. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: If request specifies 'contentIdContext', 'View' permission for the space, and permission to view the content.

Script confluence
  • Submitted by hugo697 Bun
    Created 284 days ago
    1
    //native
    2
    type Confluence = {
    3
    	email: string
    4
    	apiToken: string
    5
    	domain: string
    6
    }
    7
    /**
    8
     * Get asynchronously converted content body from the id or the current status of the task.
    9
     * Returns the asynchronous content body for the corresponding id if the task is complete 
    10
    or returns the status of the task.
    11
    
    
    12
    After the task is completed, the result can be obtained for 5 minutes, or until an identical conversion request is made again,
    13
    with allowCache query param set to false.
    14
    
    
    15
    **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
    16
    If request specifies 'contentIdContext', 'View' permission for the space, and permission to view the content.
    17
     */
    18
    export async function main(auth: Confluence, id: string) {
    19
    	const url = new URL(`https://${auth.domain}/wiki/rest/api/contentbody/convert/async/${id}`)
    20
    
    
    21
    	const response = await fetch(url, {
    22
    		method: 'GET',
    23
    		headers: {
    24
    			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
    25
    		},
    26
    		body: undefined
    27
    	})
    28
    	if (!response.ok) {
    29
    		const text = await response.text()
    30
    		throw new Error(`${response.status} ${text}`)
    31
    	}
    32
    	return await response.json()
    33
    }
    34