0

Create Proof Discussion

by
Published Oct 17, 2025

Creates a discussion on a proof.

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
 * Create Proof Discussion
8
 * Creates a discussion on a proof.
9

10
 */
11
export async function main(
12
  auth: Smartsheet,
13
  sheetId: string,
14
  proofId: string,
15
  body: { comment?: { text?: string } },
16
) {
17
  const url = new URL(
18
    `${auth.baseUrl}/sheets/${sheetId}/proofs/${proofId}/discussions`,
19
  );
20

21
  const formData = new FormData();
22
  for (const [k, v] of Object.entries(body)) {
23
    if (v !== undefined) {
24
      formData.append(k, String(v));
25
    }
26
  }
27
  const response = await fetch(url, {
28
    method: "POST",
29
    headers: {
30
      "Content-Type": "application/json",
31
      Authorization: "Bearer " + auth.token,
32
    },
33
    body: JSON.stringify(body),
34
  });
35
  if (!response.ok) {
36
    const text = await response.text();
37
    throw new Error(`${response.status} ${text}`);
38
  }
39
  return await response.json();
40
}
41