0

Get user

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 user
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  user: string,
12
  X_ZOHO_SERVICE?: string,
13
  X_ZCSRF_TOKEN?: string,
14
  If_Modified_Since?: string,
15
) {
16
  const url = new URL(`https://zohoapis.com/crm/v8/users/${user}`);
17

18
  const response = await fetch(url, {
19
    method: "GET",
20
    headers: {
21
      ...(X_ZOHO_SERVICE ? { "X-ZOHO-SERVICE": X_ZOHO_SERVICE } : {}),
22
      ...(X_ZCSRF_TOKEN ? { "X-ZCSRF-TOKEN": X_ZCSRF_TOKEN } : {}),
23
      ...(If_Modified_Since ? { "If-Modified-Since": If_Modified_Since } : {}),
24
      Authorization: "Zoho-oauthtoken " + auth.token,
25
    },
26
    body: undefined,
27
  });
28
  if (!response.ok) {
29
    const text = await response.text();
30
    throw new Error(`${response.status} ${text}`);
31
  }
32
  return await response.json();
33
}
34