type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Create Item
* Create a new content item, with one or more variants in the item's `variants` array. See [Specifying item variants](#specifying-item-variants).
The `default_locale_id` and variant `locale_id` values must be one of the locales the account has active. You can get the list with the List Locales endpoint.
#### Allowed For
* Admins, Agents
*/
export async function main(auth: Zendesk) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/dynamic_content/items`
);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 377 days ago
type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Create Item
* Create a new content item, with one or more variants in the item's `variants` array. See [Specifying item variants](#specifying-item-variants).
The `default_locale_id` and variant `locale_id` values must be one of the locales the account has active. You can get the list with the List Locales endpoint.
#### Allowed For
* Admins, Agents
*/
export async function main(auth: Zendesk) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/dynamic_content/items`
);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 923 days ago