Edits history of script submission #15290 for ' Get modules (confluence)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Confluence = {
    	email: string
    	apiToken: string
    	domain: string
    }
    /**
     * Get modules
     * Returns all modules registered dynamically by the calling app.
    
    **[Permissions](#permissions) required:** Only Connect apps can make this request.
     */
    export async function main(auth: Confluence) {
    	const url = new URL(`https://${auth.domain}/atlassian-connect/1/app/module/dynamic`)
    
    	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.text()
    }
    

    Submitted by hugo697 235 days ago