type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get comment
* Returns a comment.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:**
* *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the comment.
* If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
* If the comment has visibility restrictions, the user belongs to the group or has the role visibility is restricted to.
*/
export async function main(
auth: Jira,
issueIdOrKey: string,
id: string,
expand: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/issue/${issueIdOrKey}/comment/${id}`
);
for (const [k, v] of [["expand", expand]]) {
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 396 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Get comment
* Returns a comment.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:**
* *Browse projects* [project permission](https://confluence.atlassian.com/x/yodKLg) for the project containing the comment.
* If [issue-level security](https://confluence.atlassian.com/x/J4lKLg) is configured, issue-level security permission to view the issue.
* If the comment has visibility restrictions, the user belongs to the group or has the role visibility is restricted to.
*/
export async function main(
auth: Jira,
issueIdOrKey: string,
id: string,
expand: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/issue/${issueIdOrKey}/comment/${id}`
);
for (const [k, v] of [["expand", expand]]) {
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 948 days ago