export async function main(
zammad_host: string,
zammad_token: string,
user_agent?: string,
firstname: string,
lastname: string,
email: string,
login?: string,
organisation?: string,
roles?: string[],
) {
// https://docs.zammad.org/en/latest/api/user.html#create
const resp = await fetch(`${zammad_host}/api/v1/users`, {
method: "POST",
headers: {
Authorization: `Bearer ${zammad_token}`,
"User-Agent": user_agent ?? "Public windmill.dev script",
},
body: JSON.stringify({
firstname,
lastname,
email,
...(login && { login }),
...(organisation && { organisation }),
...(roles && { roles }),
}),
});
// HTTP 422 means that the user already exists.
if (!resp.ok && resp.status !== 422) {
throw Error(`Failed to create user: Error HTTP${resp.status}`);
}
return await resp.json();
}
Submitted by admin 503 days ago
export async function main(
zammad_host: string,
zammad_token: string,
user_agent?: string,
firstname: string,
lastname: string,
email: string,
login?: string,
organisation?: string,
roles?: string[]
) {
// https://docs.zammad.org/en/latest/api/user.html#create
const resp = await fetch(
`${zammad_host}/api/v1/users`,
{
method: "POST",
headers: {
"Authorization": `Bearer ${zammad_token}`,
"User-Agent": user_agent ?? "Public windmill.dev script",
},
body: JSON.stringify({
firstname,
lastname,
email,
...(login && {login}),
...(organisation && {organisation}),
...(roles && {roles}),
}),
},
);
// HTTP 422 means that the user already exists.
if (!resp.ok && resp.status !== 422) {
throw Error(`Failed to create user: Error HTTP${resp.status}`);
}
return await resp.json();
}
Submitted by jaller94 820 days ago
export async function main(
zammad_host: string,
zammad_token: string,
user_agent?: string,
firstname: string,
lastname: string,
email: string,
login?: string,
organisation?: string,
roles?: string[]
) {
// https://docs.zammad.org/en/latest/api/user.html#create
const resp = await fetch(
`${zammad_host}/api/v1/users`,
{
method: "POST",
headers: {
"Authorization": `Bearer ${zammad_token}`,
"User-Agent": user_agent ?? "Public windmill.dev script",
},
body: JSON.stringify({
firstname,
lastname,
email,
...(login && {login}),
...(organisation && {organisation}),
...(roles && {roles}),
}),
},
);
// HTTP 422 means that the user already exists.
if (!resp.ok || resp.status === 422) {
throw Error(`Failed to create user: Error HTTP${resp.status}`);
}
return await resp.json();
}
Submitted by jaller94 820 days ago
export async function main(
zammad_host: string,
zammad_token: string,
user_agent?: string,
firstname: string,
lastname: string,
email: string,
login?: string,
organisation?: string,
roles?: string[]
) {
https://docs.zammad.org/en/latest/api/user.html#create
const resp = await fetch(
`${zammad_host}/api/v1/users`,
{
method: "POST",
headers: {
"Authorization": `Bearer ${zammad_token}`,
"User-Agent": user_agent ?? "Public windmill.dev script",
},
body: JSON.stringify({
firstname,
lastname,
email,
...(login && {login}),
...(organisation && {organisation}),
...(roles && {roles}),
}),
},
);
// HTTP 422 means that the user already exists.
if (!resp.ok || resp.status === 422) {
throw Error(`Failed to create user: Error HTTP${resp.status}`);
}
return await resp.json();
}
Submitted by jaller94 847 days ago