Struggling to update Wordpress Custom Post Type with HTTP request - works with values, but not expression

I am trying to update a custom post type’s meta field on wordpress.

The Custom Post type was registered with JetEngine.

If I use the following expression without any variables, it updates the meta field perfectly:

{
"meta":{
"property-description":"COSPICUA - Step into the future of urban living with this MAISONETTE in the heart of Cospicua. <br /><br /> Nestled amidst a vibrant community and just a stone's throw away from all your daily needs, this architectural marvel is more than just a home; it's a lifestyle upgrade. Elegantly designed with a keen eye for detail, this MAISONETTE boasts a harmonious blend of contemporary aesthetics and functionality. "
}
} 

However, whenever I try and replace the text with a variable as follows, it gives me a JSON error:

{"meta":{"property-description":"{{ $json.property_description }}"}} 

Below the JSON box, the “result for item 1” renders exactly the same as when I type the description out in text. But when I test the node it gives me the following error:

ERROR: JSON parameter need to be an valid JSON

Please please somebody help me…

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Don’t think this is relative…

I’m running v1.31.2 on Docker Compose (self-hosted version)

Any help would really be sooo so much appreciated.

Okay I’ve come a little bit further.

If I use the following code:

{{
  {
  "meta": {
    "property-description": "$json.property_description"
  }
}
}}

The “Result for Item 1” gets rendered as:

[Object: {"meta": {"property-description": "$json.property_description"}}]

Which at least does not cause the above-mentioned JSON error.

However, it still does not work as expected. The results being:

"property-description": "$json.property_description",

Any ideas?

Success!!

So simply used:

{{
  {
  "meta": {
    "property-description": $json["property_description"]
  }
}
}}

Working as expected!!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.