//native
type Smartsheet = {
token: string;
baseUrl: string;
};
/**
* Copy Dashboard
* Creates a copy of the specified dashboard.
*/
export async function main(
auth: Smartsheet,
sightId: string,
body: {
destinationId: number;
destinationType?: "folder" | "home" | "workspace";
newName?: string;
},
) {
const url = new URL(`${auth.baseUrl}/sights/${sightId}/copy`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago