Deletes a specific file

Delete a specific file

Script xero Verified

by hugo697 ยท 12/20/2024

The script

Submitted by hugo697 Bun
Verified 515 days ago
1
//native
2
type Xero = {
3
	token: string
4
}
5
/**
6
 * Deletes a specific file
7
 * Delete a specific file
8
 */
9
export async function main(auth: Xero, FileId: string, xero_tenant_id: string) {
10
	const url = new URL(`https://api.xero.com/files.xro/1.0//Files/${FileId}`)
11

12
	const response = await fetch(url, {
13
		method: 'DELETE',
14
		headers: {
15
			Accept: 'application/json',
16
			'xero-tenant-id': xero_tenant_id,
17
			Authorization: 'Bearer ' + auth.token
18
		},
19
		body: undefined
20
	})
21
	if (!response.ok) {
22
		const text = await response.text()
23
		throw new Error(`${response.status} ${text}`)
24
	}
25
	return await response.text()
26
}
27