0

Update Member to be admin of Enterprise

by
Published Oct 30, 2023

Make Member an admin of Enterprise. NOTE: This endpoint is not available to enterprises that have opted in to user management via AdminHub.

Script trello Verified

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 398 days ago
1
type Trello = {
2
  key: string;
3
  token: string;
4
};
5
/**
6
 * Update Member to be admin of Enterprise
7
 * Make Member an admin of Enterprise.
8

9
 NOTE: This endpoint is not available to enterprises that have opted in to user management via AdminHub.
10
 */
11
export async function main(auth: Trello, id: string, idMember: string) {
12
  const url = new URL(
13
    `https://api.trello.com/1/enterprises/${id}/admins/${idMember}`
14
  );
15
  for (const [k, v] of [
16
    ["key", auth.key],
17
    ["token", auth.token],
18
  ]) {
19
    if (v !== undefined && v !== "") {
20
      url.searchParams.append(k, v);
21
    }
22
  }
23
  const response = await fetch(url, {
24
    method: "PUT",
25
    headers: {
26
      Authorization: undefined,
27
    },
28
    body: undefined,
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.text();
35
}
36