//native
type Smartsheet = {
token: string;
baseUrl: string;
};
/**
* List Attachments
* Gets a list of all attachments that are on the sheet, including sheet, row, and discussion-level attachments.
*/
export async function main(
auth: Smartsheet,
sheetId: string,
page: string | undefined,
pageSize: string | undefined,
includeAll: string | undefined,
) {
const url = new URL(`${auth.baseUrl}/sheets/${sheetId}/attachments`);
for (const [k, v] of [
["page", page],
["pageSize", pageSize],
["includeAll", includeAll],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago