Edits history of script submission #3440 for ' Set workflow for issue type in draft workflow scheme (jira)'

  • nativets
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Set workflow for issue type in draft workflow scheme
     * Sets the workflow for an issue type in a workflow scheme's draft.
    
    **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
     */
    export async function main(
      auth: Jira,
      id: string,
      issueType: string,
      body: { issueType?: string; updateDraftIfNeeded?: boolean; workflow?: string }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/workflowscheme/${id}/draft/issuetype/${issueType}`
      );
    
      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 559 days ago

  • nativets
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Set workflow for issue type in draft workflow scheme
     * Sets the workflow for an issue type in a workflow scheme's draft.
    
    **[Permissions](#permissions) required:** *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg).
     */
    export async function main(
      auth: Jira,
      id: string,
      issueType: string,
      body: { issueType?: string; updateDraftIfNeeded?: boolean; workflow?: string }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/workflowscheme/${id}/draft/issuetype/${issueType}`
      );
    
      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 1111 days ago