//native
type Box = {
token: string;
};
/**
* Query files/folders by metadata
* Create a search using SQL-like syntax to return items that match specific
metadata.
By default, this endpoint returns only the most basic info about the items for
which the query matches. To get additional fields for each item, including any
of the metadata, use the `fields` attribute in the query.
*/
export async function main(
auth: Box,
body: {
from: string;
query?: string;
query_params?: {};
ancestor_folder_id: string;
order_by?: {
field_key?: string;
direction?: "ASC" | "DESC" | "asc" | "desc";
}[];
limit?: number;
marker?: string;
fields?: string[];
},
) {
const url = new URL(`https://api.box.com/2.0/metadata_queries/execute_read`);
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