0
Remove the specific user from the project's default reviewers
One script reply has been approved by the moderators Verified

Removes a default reviewer from the project.

Example:

$ curl https://api.bitbucket.org/2.0/.../default-reviewers/%7Bf0e0e8e9-66c1-4b85-a784-44a9eb9ef1a6%7D

HTTP/1.1 204
Created by hugo697 172 days ago Viewed 3621 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 172 days ago
1
type Bitbucket = {
2
  username: string;
3
  password: string;
4
};
5
/**
6
 * Remove the specific user from the project's default reviewers
7
 * Removes a default reviewer from the project.
8

9
Example:
10
```
11
$ curl https://api.bitbucket.org/2.0/.../default-reviewers/%7Bf0e0e8e9-66c1-4b85-a784-44a9eb9ef1a6%7D
12

13
HTTP/1.1 204
14
```
15
 */
16
export async function main(
17
  auth: Bitbucket,
18
  project_key: string,
19
  selected_user: string,
20
  workspace: string
21
) {
22
  const url = new URL(
23
    `https://api.bitbucket.org/2.0/workspaces/${workspace}/projects/${project_key}/default-reviewers/${selected_user}`
24
  );
25

26
  const response = await fetch(url, {
27
    method: "DELETE",
28
    headers: {
29
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
30
    },
31
    body: undefined,
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.text();
38
}
39