Edits history of script submission #9100 for ' Create Collection Record (zixflow)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    // native
    
    type Zixflow = {
    	apiKey: string
    }
    
    export async function main(resource: Zixflow, collectionId: string, body: Record<string, any>) {
    	const endpoint = `https://api.zixflow.com/api/v1/collection-records/${collectionId}`
    
    	const response = await fetch(endpoint, {
    		method: 'POST',
    		headers: {
    			Authorization: `Bearer ${resource.apiKey}`,
    			'Content-Type': 'application/json'
    		},
    		body: JSON.stringify(body)
    	})
    
    	if (!response.ok) {
    		throw new Error(`HTTP error! status: ${response.status}`)
    	}
    
    	const data = await response.json()
    
    	return data
    }
    

    Submitted by hugo697 606 days ago