Pulling data from previous node

I’m attempting to update host name on one platform, based on another. I’m matching devices by serial number.

What is the error message (if any)?

Invalid Syntax.

"='{\n \"id\": {{ $json.assets[0].id }},\n \"company_id\": {{ $json.assets[0].company_id }},\n \"name\": {{ $('Pull SN and Name').item.json[\"device_name\"]\" }}\n }' "

Please share your workflow

Share the output returned by the last node

See above.

Information on your n8n setup

  • **n8n version: 1.05 **
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): Docker on Digital Ocean **
  • Operating system: Ubuntu 22.04.2

I meant to include this. This command line updates the hostname of the target device in Hudu:

curl -X 'PUT' \
    'https://ourtenant.huducloud.com/api/v1/companies/5/assets/3680' \
    -H 'accept: application/json' \
    -H 'x-api-key: [api-key]' \
    -H 'Content-Type: application/json' \
    -d '{
    "id": 3680,
    "company_id": 5,
    "name": "Creative Cloud iMac"

Hi @russellkg, I hope you are having a good day thus far?

The problem here will be that your expression generates a data structure that isn’t valid JSON. To avoid this you can wrap the entire object in the double curly braces {{ and }}, so n8n won’t try to mix and match JSON (the part within the double curly braces) with plain text (the part outside the braces).

So an expression like this fails:

But this will work:

Here’s a quick workflow demo:

Hope this helps! Please do let me know if you still run into any trouble with this :slight_smile:

1 Like

That did help get the node not to fail that way.

It appears I do have a working flow. I just need to add the bits and pieces to make it useful for more than one specific use case.

Thank you so much, everyone. I’m sure I’ll run into another boggle soon. (real soon now?)


1 Like

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