Edits history of script submission #15302 for ' Get theme (confluence)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Confluence = {
    	email: string
    	apiToken: string
    	domain: string
    }
    /**
     * Get theme
     * Returns a theme. This includes information about the theme name,
    description, and icon.
    
    **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: None
     */
    export async function main(auth: Confluence, themeKey: string) {
    	const url = new URL(`https://${auth.domain}/wiki/rest/api/settings/theme/${themeKey}`)
    
    	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