Edits history of script submission #3959 for ' Delete Bookmark (zendesk)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Zendesk = {
      username: string;
      password: string;
      subdomain: string;
    };
    /**
     * Delete Bookmark
     * #### Allowed For
    - Agents (own bookmarks only)
    
    If the bookmark already exists with a specified ticket id, the response status will be `http Status: 200 OK`.
     */
    export async function main(auth: Zendesk, bookmark_id: string) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/bookmarks/${bookmark_id}`
      );
    
      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 377 days ago

  • nativets
    type Zendesk = {
      username: string;
      password: string;
      subdomain: string;
    };
    /**
     * Delete Bookmark
     * #### Allowed For
    - Agents (own bookmarks only)
    
    If the bookmark already exists with a specified ticket id, the response status will be `http Status: 200 OK`.
     */
    export async function main(auth: Zendesk, bookmark_id: string) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/bookmarks/${bookmark_id}`
      );
    
      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 923 days ago