Edits history of script submission #164 for ' Get user metadata (ocs)'

  • deno
    One script reply has been approved by the moderators
    Ap­pro­ved
    // https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#user-metadata
    // Should return an XML document on success.
    type Nextcloud = {
      baseUrl: string;
      username: string;
      password: string;
    };
    export async function main(nextcloud_res: Nextcloud, userId: string) {
      const resp = await fetch(
        `${nextcloud_res.baseUrl}/ocs/v1.php/cloud/users/${encodeURIComponent(
          userId,
        )}`,
        {
          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 hugo697 380 days ago

  • deno
    // https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#user-metadata
    // Should return an XML document on success.
    type Nextcloud = {
      baseUrl: string;
      username: string;
      password: string;
    };
    export async function main(nextcloud_res: Nextcloud, userId: string) {
      const resp = await fetch(
        `${nextcloud_res.baseUrl}/ocs/v1.php/cloud/users/${encodeURIComponent(
          userId,
        )}`,
        {
          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 admin 1013 days ago

  • deno
    
    // https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#user-metadata
    // Should return an XML document on success.
    type Nextcloud = {
      baseUrl: string;
      username: string;
      password: string;
    };
    export async function main(nextcloud_res: Nextcloud, userId: string) {
      const resp = await fetch(`${nextcloud_res.baseUrl}/ocs/v1.php/cloud/users/${encodeURIComponent(userId)}`, {
        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 admin 1016 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts"
    
    // https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#user-metadata
    // Should return an XML document on success.
    export async function main(nextcloud_res: wmill.Resource<"c_nextcloud">, userId: string) {
      const resp = await fetch(`${nextcloud_res.baseUrl}/ocs/v1.php/cloud/users/${encodeURIComponent(userId)}`, {
        headers: {
          'Authorization': 'Basic ' + btoa(nextcloud_res.user + ':' + nextcloud_res.password),
          'OCS-APIRequest': 'true',
        }
      });
      if (!resp.ok) {
        throw Error(`HTTP Error ${resp.status} - ${await resp.text()}`);
      }
      return await resp.text();
    }
    

    Submitted by adam186 1144 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts"
    
    // https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#user-metadata
    // Should return an XML document on success.
    export async function main(nextcloud_res: wmill.Resource<"c_nextcloud">, userId: string) {
      const resp = await fetch(`${nextcloud_res.baseUrl}/ocs/v1.php/cloud/users/${encodeURIComponent(userId)}`, {
        headers: {
          'Authorization': 'Basic ' + btoa(nextcloud_res.user + ':' + nextcloud_res.password),
          'OCS-APIRequest': 'true',
        }
      });
      if (!resp.ok) {
        throw Error(`HTTP Error ${resp.status} - ${await resp.text()}`);
      }
      return await resp.text();
    }
    

    Submitted by adam186 1179 days ago

  • deno
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts"
    
    // https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#user-metadata
    // Should return an XML document on success.
    export async function main(nextcloud_res: wmill.Resource<"c_nextcloud">, userId: string) {
      const resp = await fetch(`${nextcloud_res.baseUrl}/ocs/v1.php/cloud/users/${encodeURIComponent(userId)}`, {
        headers: {
          'Authorization': 'Basic ' + btoa(nextcloud_res.user + ':' + nextcloud_res.password),
          'OCS-APIRequest': 'true',
        }
      });
      if (!resp.ok) {
        throw Error(`HTTP Error ${resp.status} - ${await resp.text()}`);
      }
      return await resp.text();
    }
    

    Submitted by jaller94 1329 days ago