//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Archive pages
* Archives a list of pages.
*/
export async function main(auth: Confluence, body: { pages?: { id: number }[] }) {
const url = new URL(`https://${auth.domain}/wiki/rest/api/content/archive`)
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