0
Get issue change object
One script reply has been approved by the moderators Verified

Returns the specified issue change object.

This resource is only available on repositories that have the issue tracker enabled.

Created by hugo697 320 days ago Viewed 8979 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 320 days ago
1
type Bitbucket = {
2
  username: string;
3
  password: string;
4
};
5
/**
6
 * Get issue change object
7
 * Returns the specified issue change object.
8

9
This resource is only available on repositories that have the issue
10
tracker enabled.
11
 */
12
export async function main(
13
  auth: Bitbucket,
14
  change_id: string,
15
  issue_id: string,
16
  repo_slug: string,
17
  workspace: string
18
) {
19
  const url = new URL(
20
    `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/${issue_id}/changes/${change_id}`
21
  );
22

23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
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.json();
35
}
36