Edits history of script submission #3579 for ' Update custom fields (jira)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Update custom fields
     * Updates the value of one or more custom fields on one or more issues.
     */
    export async function main(
      auth: Jira,
      generateChangelog: string | undefined,
      body: {
        updates?: {
          customField: string;
          issueIds: number[];
          value: { [k: string]: unknown };
        }[];
      }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/app/field/value`
      );
      for (const [k, v] of [["generateChangelog", generateChangelog]]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      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 396 days ago

  • nativets
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Update custom fields
     * Updates the value of one or more custom fields on one or more issues.
     */
    export async function main(
      auth: Jira,
      generateChangelog: string | undefined,
      body: {
        updates?: {
          customField: string;
          issueIds: number[];
          value: { [k: string]: unknown };
        }[];
      }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/app/field/value`
      );
      for (const [k, v] of [["generateChangelog", generateChangelog]]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      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 823 days ago

  • nativets
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Update custom fields
     * Updates the value of one or more custom fields on one or more issues. Combinations of custom field and issue should be unique within the request. 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,
      generateChangelog: string | undefined,
      body: {
        updates?: {
          customField: string;
          issueIds: number[];
          value: { [k: string]: unknown };
        }[];
      }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/app/field/value`
      );
      for (const [k, v] of [["generateChangelog", generateChangelog]]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      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 948 days ago