0

List Discussions

by
Published Oct 17, 2025

Gets a list of all discussions associated with the specified sheet. Remember that discussions are containers for the conversation thread. To see the entire thread, use the include=comments parameter.

Script smartsheet Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Smartsheet = {
3
  token: string;
4
  baseUrl: string;
5
};
6
/**
7
 * List Discussions
8
 * Gets a list of all discussions associated with the specified sheet. Remember that discussions are containers
9
for the conversation thread. To see the entire thread, use the include=comments parameter.
10

11
 */
12
export async function main(
13
  auth: Smartsheet,
14
  sheetId: string,
15
  include: "attachments" | "comments" | undefined,
16
  page: string | undefined,
17
  pageSize: string | undefined,
18
  includeAll: string | undefined,
19
) {
20
  const url = new URL(`${auth.baseUrl}/sheets/${sheetId}/discussions`);
21
  for (const [k, v] of [
22
    ["include", include],
23
    ["page", page],
24
    ["pageSize", pageSize],
25
    ["includeAll", includeAll],
26
  ]) {
27
    if (v !== undefined && v !== "" && k !== undefined) {
28
      url.searchParams.append(k, v);
29
    }
30
  }
31
  const response = await fetch(url, {
32
    method: "GET",
33
    headers: {
34
      Authorization: "Bearer " + auth.token,
35
    },
36
    body: undefined,
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.json();
43
}
44