Edits history of script submission #11088 for ' Update a submission data request (docspring)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Docspring = {
    	tokenId: string
    	tokenSecret: string
    }
    /**
     * Update a submission data request
     *
     */
    export async function main(auth: Docspring, data_request_id: string) {
    	const url = new URL(`https://api.docspring.com/api/v1/data_requests/${data_request_id}`)
    
    	const token = btoa(auth.tokenId + ':' + auth.tokenSecret)
    
    	const response = await fetch(url, {
    		method: 'PUT',
    		headers: {
    			Authorization: `Basic ${token}`
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 536 days ago