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