type Bitbucket = {
username: string;
password: string;
};
/**
* Export issues
* A POST request to this endpoint initiates a new background celery task that archives the repo's issues.
When the job has been accepted, it will return a 202 (Accepted) along with a unique url to this job in the
'Location' response header. This url is the endpoint for where the user can obtain their zip files."
*/
export async function main(
auth: Bitbucket,
repo_slug: string,
workspace: string,
body: {
type: string;
project_key?: string;
project_name?: string;
send_email?: boolean;
include_attachments?: boolean;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/export`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 430 days ago