0

Get notes

by
Published Oct 17, 2025
Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Get notes
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  fields: string,
12
  page: string | undefined,
13
  per_page: string | undefined,
14
  sort_order: string | undefined,
15
  sort_by: string | undefined,
16
  ids: string | undefined,
17
) {
18
  const url = new URL(`https://zohoapis.com/crm/v8/Notes`);
19
  for (const [k, v] of [
20
    ["page", page],
21
    ["per_page", per_page],
22
    ["fields", fields],
23
    ["sort_order", sort_order],
24
    ["sort_by", sort_by],
25
    ["ids", ids],
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: "Zoho-oauthtoken " + 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