Unable to extract multi file attachments fields from BudibaseDB for n8n automation #15071
Replies: 3 comments
-
BUDI-8875 Unable to extract multi file attachments fields from BudibaseDB for n8n automation |
Beta Was this translation helpful? Give feedback.
-
hey @iambricegg, I've converted this to a discussion. could you send some screenshots of your automation setup and the output for the steps please? |
Beta Was this translation helpful? Give feedback.
-
After a lot of tests and errors, I figure out how to make it work. It seems that sending a payload with double quote ("...") in it mess up. I use the following code to extract the informations (names and urls) without any quote : const f = [
{
"size": 479,
"name": "Color Hunt Palette e7f0dc597445658147729762.png",
"extension": "png",
"key": "app_11d87e18d32947f5b7868225896acdbd/attachments/6286465c-220d-499e-9bc2-fc36f39eee19.png",
"url": "/files/signed/prod-budi-app-assets/app_11d87e18d32947f5b7868225896acdbd/attachments/6286465c-220d-499e-9bc2-fc36f39eee19.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=budibase%2F20240626%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240626T100749Z&X-Amz-Expires=3600&X-Amz-Signature=846b15bc1518525f1826b10f6dd128265f40a3179a210832ee1b8eb04d5d2405&X-Amz-SignedHeaders=host"
},
{
"size": 2081558,
"name": "unDrawCards_1718749166782_yq13p1.png",
"extension": "png",
"key": "app_11d87e18d32947f5b7868225896acdbd/attachments/d6822d2e-252f-4c39-9cb8-0a07d90a6fa5.png",
"url": "/files/signed/prod-budi-app-assets/app_11d87e18d32947f5b7868225896acdbd/attachments/d6822d2e-252f-4c39-9cb8-0a07d90a6fa5.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=budibase%2F20240626%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240626T100749Z&X-Amz-Expires=3600&X-Amz-Signature=ed467de1e1731de0f64d067de2c75d0b9f9029e0c4cf5a0571f5d773d430b7c5&X-Amz-SignedHeaders=host"
}
];
// Convert the objects into a new array with only 'name' and 'url' properties
const pj = f.map(p => {
return {
name: p.name,
url: p.url
};
});
// Custom log format to display the result without quotes
const formattedResult = pj.map(item => {
return `{name: ${item.name}, url: ${item.url}}`;
}).join(',');
return (`[${formattedResult}]`); This code produce a result like this : [
{
name: Color Hunt Palette e7f0dc597445658147729762.png,
url: /files/signed/prod-budi-app-assets/app_11d87e18d32947f5b7868225896acdbd/attachments/6286465c-220d-499e-9bc2-fc36f39eee19.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=budibase%2F20240626%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240626T100749Z&X-Amz-Expires=3600&X-Amz-Signature=846b15bc1518525f1826b10f6dd128265f40a3179a210832ee1b8eb04d5d2405&X-Amz-SignedHeaders=host
},
{
name: unDrawCards_1718749166782_yq13p1.png,
url: /files/signed/prod-budi-app-assets/app_11d87e18d32947f5b7868225896acdbd/attachments/d6822d2e-252f-4c39-9cb8-0a07d90a6fa5.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=budibase%2F20240626%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240626T100749Z&X-Amz-Expires=3600&X-Amz-Signature=ed467de1e1731de0f64d067de2c75d0b9f9029e0c4cf5a0571f5d773d430b7c5&X-Amz-SignedHeaders=host
}
] And finally, I pass that extracted array to the n8n payload : {
"email_demandeur": "{{trigger.fields.email_demandeur}}",
"pieces_justificatives": "{{trigger.fields.pieces_justificatives}}"
} |
Beta Was this translation helpful? Give feedback.
-
Checklist
Hosting
Describe the bug
With a BudibaseDB, I have one table with multi file attachments field.
I have a form where I can upload up to 5 files to the database. The saving work well.
I'm able to extract the files names and urls with the help of the code in Budibase Docs (https://docs.budibase.com/docs/send-email#adding-attachments).
I send this payload to n8n (the extracted info is inserted in
pieces_justificatives
) :Now I try to pass this information to n8n step in automation. But always got "Invalid payload JSON".
When I remove the field from the JSON payload sent to n8n, the automation is successful. When I add it back, I got the error.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The automation run successfully.
Additional info
I also try to directly access the “attachments” field with bindings
{{ Action 3.Saved Rows.attachments }}
. But I got the same result : “Invalid JSON payload”.Anybody knows how to get this working ?
Beta Was this translation helpful? Give feedback.
All reactions