//native
type Box = {
token: string;
};
/**
* Add classification to file
* Adds a classification to a file by specifying the label of the
classification to add.
This API can also be called by including the enterprise ID in the
URL explicitly, for example
`/files/:id//enterprise_12345/securityClassification-6VMVochwUWo`.
*/
export async function main(
auth: Box,
file_id: string,
body: { Box__Security__Classification__Key?: string },
) {
const url = new URL(
`https://api.box.com/2.0/files/${file_id}/metadata/enterprise/securityClassification-6VMVochwUWo`,
);
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