Edits history of script submission #22485 for ' List user IDs (ocs)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    // Should return an XML document on success
    type Nextcloud = {
      baseUrl: string;
      username: string;
      password: string;
    };
    export async function main(nextcloud_res: Nextcloud) {
      const resp = await fetch(`${nextcloud_res.baseUrl}/ocs/v1.php/cloud/users`, {
        headers: {
          Authorization:
            "Basic " + btoa(nextcloud_res.username + ":" + nextcloud_res.password),
          "OCS-APIRequest": "true",
        },
      });
      if (!resp.ok) {
        throw Error(`HTTP Error ${resp.status} - ${await resp.text()}`);
      }
      return await resp.text();
    }
    

    Submitted by hugo989 9 days ago