type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Create related work
* Creates a related work for the given version. You can only create a generic link type of related works via this API. relatedWorkId will be auto-generated UUID, that does not need to be provided.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:** *Resolve issues:* and *Edit issues* [Managing project permissions](https://confluence.atlassian.com/adminjiraserver/managing-project-permissions-938847145.html) for the project that contains the version.
*/
export async function main(
auth: Jira,
id: string,
body: {
category: string;
issueId?: number;
relatedWorkId?: string;
title?: string;
url?: string;
}
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/version/${id}/relatedwork`
);
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.json();
}
Submitted by hugo697 327 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Create related work
* Creates a related work for the given version. You can only create a generic link type of related works via this API. relatedWorkId will be auto-generated UUID, that does not need to be provided.
This operation can be accessed anonymously.
**[Permissions](#permissions) required:** *Resolve issues:* and *Edit issues* [Managing project permissions](https://confluence.atlassian.com/adminjiraserver/managing-project-permissions-938847145.html) for the project that contains the version.
*/
export async function main(
auth: Jira,
id: string,
body: {
category: string;
issueId?: number;
relatedWorkId?: string;
title?: string;
url?: string;
}
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/version/${id}/relatedwork`
);
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.json();
}
Submitted by hugo697 879 days ago