import axios from 'axios';
const apiKey = process.env.CLICKUP_API_KEY;
const teamId = process.env.CLICKUP_TEAM_ID;
if (!apiKey) {
console.log("No API Key");
process.exit(1);
}
console.log(`API Key Length: ${apiKey.length}`);
console.log(`Team ID: ${teamId}`);
async function test() {
const client = axios.create({
baseURL: 'https://api.clickup.com/api/v2',
headers: {
'Authorization': apiKey, // verifying if trim needed?
'Content-Type': 'application/json'
}
});
try {
console.log("Testing GET /user...");
const userRes = await client.get('/user');
console.log("User Status:", userRes.status);
} catch (e) {
console.error("GET /user failed:", e.message, JSON.stringify(e.response?.data));
}
try {
console.log(`Testing getWorkspaceTasks...`);
const params = new URLSearchParams();
params.append('include_closed', 'true');
params.append('subtasks', 'true');
params.append('list_ids[]', '901309789381');
const response = await client.get(`/team/${teamId}/task`, { params });
console.log("Tasks Status:", response.status);
} catch (error) {
console.error("Tasks failed:", error.message, JSON.stringify(error.response?.data));
}
}
test();