type Bitbucket = {
username: string;
password: string;
};
/**
* List attachments for an issue
* Returns all attachments for this issue.
This returns the files' meta data. This does not return the files'
actual contents.
The files are always ordered by their upload date.
*/
export async function main(
auth: Bitbucket,
issue_id: string,
repo_slug: string,
workspace: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/${issue_id}/attachments`
);
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 377 days ago