//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Create asynchronous content body conversion tasks in bulk
* Asynchronously converts content bodies from one format to another format in bulk.
*/
export async function main(
auth: Confluence,
body: {
to: string
allowCache?: false | true
spaceKeyContext?: string
contentIdContext?: string
embeddedContentRender?: 'current' | 'version-at-save'
expand?: string[]
body: {
value: string
representation:
| 'view'
| 'export_view'
| 'styled_view'
| 'storage'
| 'editor'
| 'editor2'
| 'anonymous_export_view'
| 'wiki'
| 'atlas_doc_format'
| 'plain'
| 'raw'
}
}[]
) {
const url = new URL(`https://${auth.domain}/wiki/rest/api/contentbody/convert/async/bulk/tasks`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago