Edits history of script submission #14184 for ' Get a list of fields (bamboo_hr)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Get a list of fields
     * This endpoint can help with discovery of fields that are available in an account.
     */
    export async function main(auth: RT.BambooHr, AcceptHeaderParameter?: string) {
    	const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/meta/fields`)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			...(AcceptHeaderParameter ? { AcceptHeaderParameter: AcceptHeaderParameter } : {}),
    			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
    		},
    		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