0
Get field reference data (POST)
One script reply has been approved by the moderators Verified

Returns reference data for JQL searches.

Created by hugo697 616 days ago Viewed 22506 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 616 days ago
1
type Jira = {
2
  username: string;
3
  password: string;
4
  domain: string;
5
};
6
/**
7
 * Get field reference data (POST)
8
 * Returns reference data for JQL searches.
9
 */
10
export async function main(
11
  auth: Jira,
12
  body: { includeCollapsedFields?: boolean; projectIds?: number[] }
13
) {
14
  const url = new URL(
15
    `https://${auth.domain}.atlassian.net/rest/api/2/jql/autocompletedata`
16
  );
17

18
  const response = await fetch(url, {
19
    method: "POST",
20
    headers: {
21
      "Content-Type": "application/json",
22
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
23
    },
24
    body: JSON.stringify(body),
25
  });
26
  if (!response.ok) {
27
    const text = await response.text();
28
    throw new Error(`${response.status} ${text}`);
29
  }
30
  return await response.json();
31
}
32