type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get changelogs
* Returns a [paginated](#pagination) list of all changelogs for an issue sorted by date, starting from the oldest.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:**
* *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.
* If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
*/
export async function main(
auth: Jira,
issueIdOrKey: string,
startAt: string | undefined,
maxResults: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/issue/${issueIdOrKey}/changelog`
);
for (const [k, v] of [
["startAt", startAt],
["maxResults", maxResults],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 327 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get changelogs
* Returns a [paginated](#pagination) list of all changelogs for an issue sorted by date, starting from the oldest.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:**
* *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project that the issue is in.
* If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
*/
export async function main(
auth: Jira,
issueIdOrKey: string,
startAt: string | undefined,
maxResults: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/issue/${issueIdOrKey}/changelog`
);
for (const [k, v] of [
["startAt", startAt],
["maxResults", maxResults],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 879 days ago