Edits history of script submission #15298 for ' Get space 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 space theme
     * Returns the theme selected for a space, if one is set. If no space
    theme is set, this means that the space is inheriting the global look
    and feel settings.
    
    **[Permissions required](https://confluence.atlassian.com/x/_AozKw)**: ‘View’ permission for the space.
     */
    export async function main(auth: Confluence, spaceKey: string) {
    	const url = new URL(`https://${auth.domain}/wiki/rest/api/space/${spaceKey}/theme`)
    
    	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