W n8n
This commit is contained in:
parent
2868f8ba95
commit
b790b9d9cf
@ -254,9 +254,22 @@ export async function POST(request: Request) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const workflowResult = await n8nService.triggerMissionCreation({
|
const workflowResult = await n8nService.triggerMissionCreation({
|
||||||
...body,
|
|
||||||
missionId: mission.id,
|
missionId: mission.id,
|
||||||
creatorId: mission.creatorId
|
name: mission.name,
|
||||||
|
creatorId: mission.creatorId,
|
||||||
|
oddScope: mission.oddScope,
|
||||||
|
niveau: mission.niveau,
|
||||||
|
intention: mission.intention,
|
||||||
|
missionType: mission.missionType,
|
||||||
|
donneurDOrdre: mission.donneurDOrdre,
|
||||||
|
projection: mission.projection,
|
||||||
|
services: mission.services,
|
||||||
|
participation: mission.participation,
|
||||||
|
profils: mission.profils,
|
||||||
|
config: {
|
||||||
|
N8N_API_KEY: process.env.N8N_API_KEY,
|
||||||
|
MISSION_API_URL: process.env.NEXT_PUBLIC_API_URL || 'https://localhost:3000/api'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Received workflow result:', JSON.stringify(workflowResult, null, 2));
|
console.log('Received workflow result:', JSON.stringify(workflowResult, null, 2));
|
||||||
|
|||||||
@ -30,6 +30,17 @@ export class N8nService {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Log the exact data structure being sent
|
||||||
|
console.log('Data structure being sent to n8n:', {
|
||||||
|
missionId: dataWithDefaults.missionId,
|
||||||
|
name: dataWithDefaults.name,
|
||||||
|
creatorId: dataWithDefaults.creatorId,
|
||||||
|
hasConfig: !!dataWithDefaults.config,
|
||||||
|
configKeys: dataWithDefaults.config ? Object.keys(dataWithDefaults.config) : [],
|
||||||
|
apiKeyPresent: !!dataWithDefaults.config?.N8N_API_KEY,
|
||||||
|
apiUrlPresent: !!dataWithDefaults.config?.MISSION_API_URL
|
||||||
|
});
|
||||||
|
|
||||||
console.log('Triggering n8n workflow with data:', JSON.stringify(dataWithDefaults, null, 2));
|
console.log('Triggering n8n workflow with data:', JSON.stringify(dataWithDefaults, null, 2));
|
||||||
console.log('Using webhook URL:', this.webhookUrl);
|
console.log('Using webhook URL:', this.webhookUrl);
|
||||||
console.log('API key present:', !!this.apiKey);
|
console.log('API key present:', !!this.apiKey);
|
||||||
@ -61,6 +72,13 @@ export class N8nService {
|
|||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorText = await response.text();
|
const errorText = await response.text();
|
||||||
console.error('Webhook error response:', errorText);
|
console.error('Webhook error response:', errorText);
|
||||||
|
// Try to parse the error response as JSON for more details
|
||||||
|
try {
|
||||||
|
const errorJson = JSON.parse(errorText);
|
||||||
|
console.error('Parsed error response:', errorJson);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error response is not JSON');
|
||||||
|
}
|
||||||
throw new Error(`HTTP error! status: ${response.status}, body: ${errorText}`);
|
throw new Error(`HTTP error! status: ${response.status}, body: ${errorText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user