//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Delete user property
* Deletes a property for the given user.
For more information about user properties, see
[Confluence entity properties](https://developer.atlassian.com/cloud/confluence/confluence-entity-properties/).
`Note`, these properties stored against a user are on a Confluence site level and not space/content level.
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
Permission to access the Confluence site ('Can use' global permission).
*/
export async function main(auth: Confluence, userId: string, key: string) {
const url = new URL(`https://${auth.domain}/wiki/rest/api/user/${userId}/property/${key}`)
const response = await fetch(url, {
method: 'DELETE',
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.text()
}
Submitted by hugo697 235 days ago