-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathtest-direct-api.js
More file actions
51 lines (41 loc) · 1.38 KB
/
test-direct-api.js
File metadata and controls
51 lines (41 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
/**
* Test n8n API directly (bypassing MCP) to see if 409 error is from n8n or our code
*/
const axios = require('axios');
const fs = require('fs');
// Load config
const config = JSON.parse(fs.readFileSync('.config.json', 'utf8'));
const env = config.environments[config.defaultEnv];
const api = axios.create({
baseURL: `${env.n8n_host}/api/v1`,
headers: {
'X-N8N-API-KEY': env.n8n_api_key,
'Content-Type': 'application/json'
}
});
async function test() {
try {
console.error('[INFO] Testing direct n8n API...');
console.error(`[INFO] Base URL: ${env.n8n_host}/api/v1`);
// Try to create a tag
const tagName = `DirectTest_${Date.now()}_${Math.random().toString(36).substring(7)}`;
console.error(`\n[INFO] Creating tag: ${tagName}`);
const response = await api.post('/tags', { name: tagName });
console.error('[SUCCESS] Tag created!');
console.error(JSON.stringify(response.data, null, 2));
// Clean up
console.error(`\n[INFO] Cleaning up tag: ${response.data.id}`);
await api.delete(`/tags/${response.data.id}`);
console.error('[SUCCESS] Tag deleted');
} catch (error) {
console.error('[ERROR] Request failed:');
if (error.response) {
console.error(`Status: ${error.response.status}`);
console.error(`Data:`, error.response.data);
} else {
console.error(error.message);
}
}
}
test();