//native
/**
* Add Comment
* Add a comment to a file. The comment is unanchored (it applies to the whole file, not a text selection); mention someone by writing +email@example.com in the content.
*/
export async function main(auth: RT.Gdrive, file_id: string, content: string) {
const url = new URL(
`https://www.googleapis.com/drive/v3/files/${file_id}/comments`
)
url.searchParams.append("fields", "*")
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({ content }),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago