0

Get Row

by
Published Oct 17, 2025

Gets the row specified in the URL.

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
 * Get Row
8
 * Gets the row specified in the URL.
9
 */
10
export async function main(
11
  auth: Smartsheet,
12
  sheetId: string,
13
  rowId: string,
14
  accessApiLevel: string | undefined,
15
  include: "columns" | "filters" | undefined,
16
  exclude:
17
    | "filteredOutRows"
18
    | "linkInFromCellDetails"
19
    | "linksOutToCellsDetails"
20
    | "nonexistentCells"
21
    | undefined,
22
  level: string | undefined,
23
) {
24
  const url = new URL(
25
    `${auth.baseUrl}/sheets/${sheetId}/rows/${rowId}`,
26
  );
27
  for (const [k, v] of [
28
    ["accessApiLevel", accessApiLevel],
29
    ["include", include],
30
    ["exclude", exclude],
31
    ["level", level],
32
  ]) {
33
    if (v !== undefined && v !== "" && k !== undefined) {
34
      url.searchParams.append(k, v);
35
    }
36
  }
37
  const response = await fetch(url, {
38
    method: "GET",
39
    headers: {
40
      Authorization: "Bearer " + auth.token,
41
    },
42
    body: undefined,
43
  });
44
  if (!response.ok) {
45
    const text = await response.text();
46
    throw new Error(`${response.status} ${text}`);
47
  }
48
  return await response.json();
49
}
50