0

Update project

by
Published Oct 17, 2025

Update details of a project.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Update project
7
 * Update details of a project.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  project_id: string,
12
  organization_id: string | undefined,
13
  body: {
14
    project_name: string;
15
    customer_id: string;
16
    currency_id?: string;
17
    description?: string;
18
    billing_type: string;
19
    rate?: string;
20
    budget_type?: string;
21
    budget_hours?: string;
22
    budget_amount?: string;
23
    cost_budget_amount?: number;
24
    user_id: string;
25
    tasks?: {
26
      task_name: string;
27
      description?: string;
28
      rate?: string;
29
      budget_hours?: string;
30
    }[];
31
    users?: {
32
      user_id?: string;
33
      is_current_user?: false | true;
34
      user_name?: string;
35
      email?: string;
36
      user_role?: string;
37
      status?: string;
38
      rate?: string;
39
      budget_hours?: string;
40
      total_hours?: string;
41
      billed_hours?: string;
42
      un_billed_hours?: string;
43
      cost_rate?: number;
44
    }[];
45
  },
46
) {
47
  const url = new URL(
48
    `https://www.zohoapis.com/books/v3/projects/${project_id}`,
49
  );
50
  for (const [k, v] of [["organization_id", organization_id]]) {
51
    if (v !== undefined && v !== "" && k !== undefined) {
52
      url.searchParams.append(k, v);
53
    }
54
  }
55
  const response = await fetch(url, {
56
    method: "PUT",
57
    headers: {
58
      "Content-Type": "application/json",
59
      Authorization: "Zoho-oauthtoken " + auth.token,
60
    },
61
    body: JSON.stringify(body),
62
  });
63
  if (!response.ok) {
64
    const text = await response.text();
65
    throw new Error(`${response.status} ${text}`);
66
  }
67
  return await response.json();
68
}
69