Hey,
I’m trying to transfer some data from a text field in Airtable to a custom post type ACF field in Wordpress. Everything works fine, but if the text field in Airtable has any line breaks, it throws an error:
“ERROR: The data in “Body Parameters” is no valid JSON. Set Body Content Type to “RAW/Custom” for XML or other types of payloads”.
Below is my workflow:
Hi @Darius_Dumitru, it seems your expression is building an invalid JSON data if it includes line breaks.
This happens because your expression is a (JSON-like) string rather than a JSON object. To return a valid JSON object you could wrap your entire expression inside {{
and }}
and avoid mixing it with any text outside of these markers.
Here’s an example showing both approaches:
The top HTTP Request node (Invalid JSON) will run into the error you have described:
The bottom one (Valid JSON) will run fine:
Hope this helps!
@MutedJam thanks for the reply. I tried to wrap all the expression with {{ }} but it gives me the same error. Strange thing is that when I wrap the expression, the “Body Parameters” looks blank (attached screenshot). Do you have any idea why?
Can you share your workflow including the updated expression and also an example JSON dataset returned by your Airtable Trigger node? Feel free to redact the actual values, I’d just like to understand the exact data structure you’re working. Make sure to extract it like so to get the raw data:
@MutedJam here it is:
and here is the Airtable dataset:
[
{
"id": "recMBfk0",
"createdTime": "2022-08-27T09:59:37.000Z",
"fields": {
"Project ID": "Test test - Website Build",
"Date In": "2022-08-29",
"LifeTime Recuring Value": {
"specialValue": "NaN"
},
"Work hours": 13,
"Week day": 1,
"NOW": "2022-08-29T09:06:11.656Z",
"Password Generator": "2022!",
"Contact Name": "Test test",
"Contact": [
"recPBCQOs"
],
"Email (from Contact)": [
"[email protected]"
],
"Phone (from Contact)": [
"(075) 777777"
],
"Referral Source": [
"Google Ads"
],
"Last Time": "2022-08-28T09:58:23.000Z",
"Company Name": [
"Project Template"
],
"Services": [
"Website Build"
],
"Project Value": 2000,
"Lifetime Value(Project+Lifetime Recuring)": {
"specialValue": "NaN"
},
"Monthly Retainer": 150,
"Status": "Prospect Qualified",
"Last Modified Status": "2022-08-27T10:03:14.000Z",
"Investitia include": "- Feature #1\n- Feature #2\n- Feature #3\n- Feature #4\n",
"Tasks": [
"rechGSDP9DB"
],
"Task Name (from Tasks)": [
"📝 Send Proposal Test test ℹ️ Prospect Qualified"
]
}
}
]
Hi @Darius_Dumitru, many thanks for confirming! It seems your current expression still uses {{
and }}
for the individual values. Once you get rid of these and make sure your expression doesn’t span multiple lines it should work as intended. Try out this example (I’ve replaced the URLs with test URLs I have access to, so you would need to switch them back):
n8n will also indicate you have a valid JSON object:
1 Like
@MutedJam it works perfectly! Thanks a lot!!
1 Like
Glad to hear, thx so much for confirming!
1 Like
@MutedJam I happened to have this error again. The problem is that without the “{{ }}” it says Invalid JSON. But when I add those “{{ }}”, the JSON is just empty.
If I remove the “{{ }}” and just have the expression without new lines, everything is working fine.
Here are 2 screenshots regarding this. Can you please help me again?