//native
type Zoho = {
token: string;
};
/**
* Upload organization photo
*
*/
export async function main(auth: Zoho, body: { file?: {} }) {
const url = new URL(`https://zohoapis.com/crm/v8/org/photo`);
const formData = new FormData();
for (const [k, v] of Object.entries(body)) {
if (v !== undefined && v !== "") {
formData.append(k, String(v));
}
}
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Zoho-oauthtoken " + auth.token,
},
body: formData,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago