Edits history of script submission #3978 for ' Delete User Field Option (zendesk)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Zendesk = {
      username: string;
      password: string;
      subdomain: string;
    };
    /**
     * Delete User Field Option
     * #### Allowed for
    * Admins
    
     */
    export async function main(
      auth: Zendesk,
      user_field_id: string,
      user_field_option_id: string
    ) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/user_fields/${user_field_id}/options/${user_field_option_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 User Field Option
     * #### Allowed for
    * Admins
    
     */
    export async function main(
      auth: Zendesk,
      user_field_id: string,
      user_field_option_id: string
    ) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/user_fields/${user_field_id}/options/${user_field_option_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