W n8n
This commit is contained in:
parent
8476e1d838
commit
4fa5182abb
@ -144,13 +144,11 @@ export async function POST(request: Request) {
|
|||||||
// Validate required fields
|
// Validate required fields
|
||||||
const requiredFields = {
|
const requiredFields = {
|
||||||
name,
|
name,
|
||||||
oddScope,
|
|
||||||
niveau,
|
niveau,
|
||||||
intention,
|
intention,
|
||||||
missionType,
|
missionType,
|
||||||
donneurDOrdre,
|
donneurDOrdre,
|
||||||
projection,
|
projection
|
||||||
participation
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const missingFields = Object.entries(requiredFields)
|
const missingFields = Object.entries(requiredFields)
|
||||||
@ -180,7 +178,7 @@ export async function POST(request: Request) {
|
|||||||
const mission = await prisma.mission.create({
|
const mission = await prisma.mission.create({
|
||||||
data: {
|
data: {
|
||||||
name,
|
name,
|
||||||
oddScope,
|
oddScope: oddScope || 'default',
|
||||||
niveau,
|
niveau,
|
||||||
intention,
|
intention,
|
||||||
missionType,
|
missionType,
|
||||||
@ -188,7 +186,7 @@ export async function POST(request: Request) {
|
|||||||
projection,
|
projection,
|
||||||
services: Array.isArray(services) ? services.filter(Boolean) : [],
|
services: Array.isArray(services) ? services.filter(Boolean) : [],
|
||||||
profils: Array.isArray(profils) ? profils.filter(Boolean) : [],
|
profils: Array.isArray(profils) ? profils.filter(Boolean) : [],
|
||||||
participation,
|
participation: participation || 'default',
|
||||||
creatorId: userId
|
creatorId: userId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -18,16 +18,18 @@ export class N8nService {
|
|||||||
|
|
||||||
async triggerMissionCreation(data: any): Promise<any> {
|
async triggerMissionCreation(data: any): Promise<any> {
|
||||||
try {
|
try {
|
||||||
// Add API key to the data
|
// Add API key and default values to the data
|
||||||
const dataWithApiKey = {
|
const dataWithDefaults = {
|
||||||
...data,
|
...data,
|
||||||
|
oddScope: data.oddScope || 'default',
|
||||||
|
participation: data.participation || 'default',
|
||||||
config: {
|
config: {
|
||||||
...data.config,
|
...data.config,
|
||||||
N8N_API_KEY: this.apiKey
|
N8N_API_KEY: this.apiKey
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('Triggering n8n workflow with data:', JSON.stringify(dataWithApiKey, 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);
|
||||||
|
|
||||||
@ -39,7 +41,7 @@ export class N8nService {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'x-api-key': this.apiKey
|
'x-api-key': this.apiKey
|
||||||
},
|
},
|
||||||
body: dataWithApiKey
|
body: dataWithDefaults
|
||||||
};
|
};
|
||||||
console.log('Full request details:', JSON.stringify(requestDetails, null, 2));
|
console.log('Full request details:', JSON.stringify(requestDetails, null, 2));
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ export class N8nService {
|
|||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'x-api-key': this.apiKey
|
'x-api-key': this.apiKey
|
||||||
},
|
},
|
||||||
body: JSON.stringify(dataWithApiKey),
|
body: JSON.stringify(dataWithDefaults),
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Webhook response status:', response.status);
|
console.log('Webhook response status:', response.status);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user