0

List user IDs

by
Published Oct 1, 2022

https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#user-metadata-list-user-ids

Script ocs Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 9 days ago
1
//native
2

3
// Should return an XML document on success
4
type Nextcloud = {
5
  baseUrl: string;
6
  username: string;
7
  password: string;
8
};
9
export async function main(nextcloud_res: Nextcloud) {
10
  const resp = await fetch(`${nextcloud_res.baseUrl}/ocs/v1.php/cloud/users`, {
11
    headers: {
12
      Authorization:
13
        "Basic " + btoa(nextcloud_res.username + ":" + nextcloud_res.password),
14
      "OCS-APIRequest": "true",
15
    },
16
  });
17
  if (!resp.ok) {
18
    throw Error(`HTTP Error ${resp.status} - ${await resp.text()}`);
19
  }
20
  return await resp.text();
21
}
22

Other submissions
  • Submitted by jaller94 Deno
    Created 401 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