This commit is contained in:
alma 2025-05-22 18:56:39 +02:00
parent 2868f8ba95
commit b790b9d9cf
2 changed files with 33 additions and 2 deletions

View File

@ -254,9 +254,22 @@ export async function POST(request: Request) {
try {
const workflowResult = await n8nService.triggerMissionCreation({
...body,
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));

View File

@ -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('Using webhook URL:', this.webhookUrl);
console.log('API key present:', !!this.apiKey);
@ -61,6 +72,13 @@ export class N8nService {
if (!response.ok) {
const errorText = await response.text();
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}`);
}