Deletes an existing file association

By passing in the appropriate options, you can create a new folder

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 an existing file association
7
 * By passing in the appropriate options, you can create a new folder
8
 */
9
export async function main(auth: Xero, FileId: string, ObjectId: string, xero_tenant_id: string) {
10
	const url = new URL(
11
		`https://api.xero.com/files.xro/1.0//Files/${FileId}/Associations/${ObjectId}`
12
	)
13

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