0
List user IDs
One script reply has been approved by the moderators Verified
Created by jaller94 545 days ago Viewed 2435 times
0
Submitted by jaller94 Deno
Verified 545 days ago
1
// Should return an XML document on success
2
type Nextcloud = {
3
  baseUrl: string;
4
  username: string;
5
  password: string;
6
};
7
export async function main(nextcloud_res: Nextcloud) {
8
  const resp = await fetch(`${nextcloud_res.baseUrl}/ocs/v1.php/cloud/users`, {
9
    headers: {
10
      Authorization:
11
        "Basic " + btoa(nextcloud_res.username + ":" + nextcloud_res.password),
12
      "OCS-APIRequest": "true",
13
    },
14
  });
15
  if (!resp.ok) {
16
    throw Error(`HTTP Error ${resp.status} - ${await resp.text()}`);
17
  }
18
  return await resp.text();
19
}
20