Edits history of script submission #15115 for ' Get validation results (codat)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Codat = {
    	encodedKey: string
    }
    /**
     * Get validation results
     * Use the **Get validation results** endpoint to review warnings and errors encountered during the data type validation phase.
    
    The validation result [schema](https://docs.codat.io/platform-api#/schemas/ValidationResult) contains two message arrays:
    
    - **`warnings`** array lists potential issues with the data type that may require attention but don't block usage.
    - **`errors`** array contains critical issues that must be resolved before the data type can be used.
     */
    export async function main(auth: Codat, companyId: string, datasetId: string) {
    	const url = new URL(`https://api.codat.io/companies/${companyId}/sync/${datasetId}/validation`)
    
    	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