//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Gets available content states for content.
* Gets content states that are available for the content to be set as.
Will return all enabled Space Content States.
Will only return most the 3 most recently published custom content states to match UI editor list.
To get all custom content states, use the /content-states endpoint.
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
Permission to edit the content.
*/
export async function main(auth: Confluence, id: string) {
const url = new URL(`https://${auth.domain}/wiki/rest/api/content/${id}/state/available`)
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago