Edits history of script submission #3388 for ' Delete comment property (jira)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Delete comment property
     * Deletes a comment property.
    
    **[Permissions](#permissions) required:** either of:
    
     *  *Edit All Comments* [project permission](https://confluence.atlassian.com/x/yodKLg) to delete a property from any comment.
     *  *Edit Own Comments* [project permission](https://confluence.atlassian.com/x/yodKLg) to delete a property from a comment created by the user.
    
    Also, when the visibility of a comment is restricted to a role or group the user must be a member of that role or group.
     */
    export async function main(auth: Jira, commentId: string, propertyKey: string) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/comment/${commentId}/properties/${propertyKey}`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        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.text();
    }
    

    Submitted by hugo697 396 days ago

  • nativets
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Delete comment property
     * Deletes a comment property.
    
    **[Permissions](#permissions) required:** either of:
    
     *  *Edit All Comments* [project permission](https://confluence.atlassian.com/x/yodKLg) to delete a property from any comment.
     *  *Edit Own Comments* [project permission](https://confluence.atlassian.com/x/yodKLg) to delete a property from a comment created by the user.
    
    Also, when the visibility of a comment is restricted to a role or group the user must be a member of that role or group.
     */
    export async function main(auth: Jira, commentId: string, propertyKey: string) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/comment/${commentId}/properties/${propertyKey}`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        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.text();
    }
    

    Submitted by hugo697 948 days ago