type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Update custom field value
* Updates the value of a custom field on one or more issues.
*/
export async function main(
auth: Jira,
fieldIdOrKey: string,
generateChangelog: string | undefined,
body: { updates?: { issueIds: number[]; value: { [k: string]: unknown } }[] }
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/app/field/${fieldIdOrKey}/value`
);
for (const [k, v] of [["generateChangelog", generateChangelog]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
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 396 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Update custom field value
* Updates the value of a custom field on one or more issues.
*/
export async function main(
auth: Jira,
fieldIdOrKey: string,
generateChangelog: string | undefined,
body: { updates?: { issueIds: number[]; value: { [k: string]: unknown } }[] }
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/app/field/${fieldIdOrKey}/value`
);
for (const [k, v] of [["generateChangelog", generateChangelog]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
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 823 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Update custom field value
* Updates the value of a custom field on one or more issues. Custom fields can only be updated by the Forge app that created them.
**[Permissions](#permissions) required:** Only the app that created the custom field can update its values with this operation.
*/
export async function main(
auth: Jira,
fieldIdOrKey: string,
generateChangelog: string | undefined,
body: { updates?: { issueIds: number[]; value: { [k: string]: unknown } }[] }
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/app/field/${fieldIdOrKey}/value`
);
for (const [k, v] of [["generateChangelog", generateChangelog]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
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 948 days ago