Edits history of script submission #15186 for ' Refresh custom data type (codat)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Codat = {
    	encodedKey: string
    }
    /**
     * Refresh custom data type
     * The *Refresh custom data type* endpoint refreshes the specified custom data type for a given company. This is an asynchronous operation that will sync updated data from the linked integration into Codat for you to view.
     */
    export async function main(
    	auth: Codat,
    	companyId: string,
    	connectionId: string,
    	customDataIdentifier: string
    ) {
    	const url = new URL(
    		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/queue/custom/${customDataIdentifier}`
    	)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		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