0

Update Dashboard

by
Published Oct 17, 2025

Updates (renames) the specified dashboard.

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
 * Update Dashboard
8
 * Updates (renames) the specified dashboard.
9
 */
10
export async function main(
11
  auth: Smartsheet,
12
  sightId: string,
13
  numericDates: string | undefined,
14
  body: { name?: string },
15
) {
16
  const url = new URL(`${auth.baseUrl}/sights/${sightId}`);
17
  for (const [k, v] of [["numericDates", numericDates]]) {
18
    if (v !== undefined && v !== "" && k !== undefined) {
19
      url.searchParams.append(k, v);
20
    }
21
  }
22
  const response = await fetch(url, {
23
    method: "PUT",
24
    headers: {
25
      "Content-Type": "application/json",
26
      Authorization: "Bearer " + auth.token,
27
    },
28
    body: JSON.stringify(body),
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36