Edits history of script submission #1333 for ' Update an issue (bitbucket)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update an issue
     * Modifies the issue.
     */
    export async function main(
      auth: Bitbucket,
      issue_id: string,
      repo_slug: string,
      workspace: string
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/${issue_id}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 375 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update an issue
     * Modifies the issue.
     */
    export async function main(
      auth: Bitbucket,
      issue_id: string,
      repo_slug: string,
      workspace: string
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/${issue_id}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 935 days ago

  • nativets
    type Bitbucket = {
      username: string;
      password: string;
    };
    /**
     * Update an issue
     * Modifies the issue.
    
    ```
    $ curl https://api.bitbucket.org/2.0/repostories/evzijst/dogslow/issues/123 \
      -u evzijst -s -X PUT -H 'Content-Type: application/json' \
      -d '{
      "title": "Updated title",
      "assignee": {
        "account_id": "5d5355e8c6b9320d9ea5b28d"
      },
      "priority": "minor",
      "version": {
        "name": "1.0"
      },
      "component": null
    }'
    ```
    
    This example changes the `title`, `assignee`, `priority` and the
    `version`. It also removes the value of the `component` from the issue
    by setting the field to `null`. Any field not present keeps its existing
    value.
    
    Each time an issue is edited in the UI or through the API, an immutable
    change record is created under the `/issues/123/changes` endpoint. It
    also has a comment associated with the change.
     */
    export async function main(
      auth: Bitbucket,
      issue_id: string,
      repo_slug: string,
      workspace: string
    ) {
      const url = new URL(
        `https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/issues/${issue_id}`
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 935 days ago