Edits history of script submission #15050 for ' Get custom data configuration (codat)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Codat = {
    	encodedKey: string
    }
    /**
     * Get custom data configuration
     * The *Get custom data configuration* endpoint returns existing configuration details for the specified custom data type and integration pair you previously configured.
    
    A [custom data type](https://docs.codat.io/using-the-api/custom-data) is an additional data type you can create that is not included in Codat's standardized data model.
     */
    export async function main(auth: Codat, platformKey: string, customDataIdentifier: string) {
    	const url = new URL(
    		`https://api.codat.io/integrations/${platformKey}/dataTypes/custom/${customDataIdentifier}`
    	)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: `Basic ${auth.encodedKey}`
    		},
    		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