41 lines
1 KiB
JavaScript
41 lines
1 KiB
JavaScript
|
|
// Quick test to fetch time entry 438553 from Autotask API
|
||
|
|
const https = require('https');
|
||
|
|
|
||
|
|
const apiUrl = process.env.AUTOTASK_API_URL || 'https://webservices1.autotask.net/atservicesrest/v1.0';
|
||
|
|
const username = process.env.AUTOTASK_USERNAME;
|
||
|
|
const password = process.env.AUTOTASK_PASSWORD;
|
||
|
|
const integrationCode = process.env.AUTOTASK_INTEGRATION_CODE;
|
||
|
|
|
||
|
|
const auth = Buffer.from(`${username}:${password}`).toString('base64');
|
||
|
|
|
||
|
|
const options = {
|
||
|
|
hostname: 'webservices1.autotask.net',
|
||
|
|
path: '/atservicesrest/v1.0/TimeEntries/438553',
|
||
|
|
method: 'GET',
|
||
|
|
headers: {
|
||
|
|
'Authorization': `Basic ${auth}`,
|
||
|
|
'ApiIntegrationCode': integrationCode,
|
||
|
|
'Content-Type': 'application/json'
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
const req = https.request(options, (res) => {
|
||
|
|
let data = '';
|
||
|
|
|
||
|
|
res.on('data', (chunk) => {
|
||
|
|
data += chunk;
|
||
|
|
});
|
||
|
|
|
||
|
|
res.on('end', () => {
|
||
|
|
console.log('Status Code:', res.statusCode);
|
||
|
|
console.log('Response:');
|
||
|
|
console.log(JSON.stringify(JSON.parse(data), null, 2));
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
req.on('error', (error) => {
|
||
|
|
console.error('Error:', error);
|
||
|
|
});
|
||
|
|
|
||
|
|
req.end();
|