Skip to main content
Glama
test-client-axios.jsโ€ข4.08 kB
#!/usr/bin/env node /** * Test script to examine client object structure */ const { config } = require('dotenv'); const { AutotaskService } = require('../dist/services/autotask.service.js'); const winston = require('winston'); // Load environment variables config(); const logger = winston.createLogger({ level: 'info', format: winston.format.combine( winston.format.timestamp(), winston.format.json() ), transports: [ new winston.transports.Console() ] }); async function examineClientStructure() { console.log('๐Ÿ” Examining client object structure...\n'); // Create the service const serviceConfig = { autotask: { username: process.env.AUTOTASK_USERNAME, secret: process.env.AUTOTASK_SECRET, integrationCode: process.env.AUTOTASK_INTEGRATION_CODE } }; if (!serviceConfig.autotask.username || !serviceConfig.autotask.secret || !serviceConfig.autotask.integrationCode) { console.error('โŒ Missing required environment variables'); process.exit(1); } const autotaskService = new AutotaskService(serviceConfig, logger); try { // Initialize and get client await autotaskService.initialize(); const client = await autotaskService.ensureClient(); console.log('๐Ÿ“‹ Client object properties:'); console.log(' Keys:', Object.keys(client)); // Check for axios property if (client.axios) { console.log('โœ… Found axios property'); console.log(' Axios properties:', Object.keys(client.axios)); } else { console.log('โŒ No axios property found'); } // Check what properties exist console.log('\n๐Ÿ“‹ Available properties:'); Object.keys(client).forEach(key => { const value = client[key]; console.log(` ${key}: ${typeof value} ${Array.isArray(value) ? '(array)' : ''}`); }); // Test both working companies and broken projects console.log('\n๐Ÿงช Testing direct API calls...'); // Test 1: Working Companies call console.log('\n1๏ธโƒฃ Testing Companies (known working):'); try { if (client.axios && typeof client.axios.post === 'function') { const companiesResponse = await client.axios.post('/Companies/query', { filter: [{ op: "gte", field: "id", value: 0 }], includeFields: ["id", "companyName"], pageSize: 1 }); console.log(' โœ… Companies query SUCCESS'); console.log(' ๐Ÿ“Š Response format:', { dataType: typeof companiesResponse.data, hasItems: !!companiesResponse.data?.items, itemCount: companiesResponse.data?.items?.length || 0 }); } else { console.log(' โŒ client.axios.post not available'); } } catch (error) { console.log(' โŒ Companies query FAILED:', error.message); } // Test 2: Projects call (the problematic one) console.log('\n2๏ธโƒฃ Testing Projects (problematic):'); try { if (client.axios && typeof client.axios.post === 'function') { const projectsResponse = await client.axios.post('/Projects/query', { filter: [{ op: "gte", field: "id", value: 0 }], includeFields: ["id", "projectName"], pageSize: 1 }); console.log(' โœ… Projects query SUCCESS'); console.log(' ๐Ÿ“Š Response format:', { dataType: typeof projectsResponse.data, hasItems: !!projectsResponse.data?.items, itemCount: projectsResponse.data?.items?.length || 0 }); } else { console.log(' โŒ client.axios.post not available'); } } catch (error) { console.log(' โŒ Projects query FAILED:', error.response?.status, error.response?.statusText); console.log(' ๐Ÿ“‹ Error details:', error.response?.data?.errors || error.message); } } catch (error) { console.error('โŒ Failed to examine client:', error.message); } } // Run the test examineClientStructure().catch(error => { console.error('โŒ Test failed:', error.message); process.exit(1); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/asachs01/autotask-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server