//native
// 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 hugo989 9 days ago