//native
type Confluence = {
email: string
apiToken: string
domain: string
}
/**
* Get user property
* Returns the property corresponding to `key` for a 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: '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