I'm stuck in something basic

Hi n8ners, I’m a newbie here and I’m having problems referencing data from one node to another.

From the first node I get a JSON with all the info from a Podio app, and I want chatgpt to create the DDL of a MySQL table with the same structure. Should be easy, but…

If I copy/paste the full JSON into the OpenAI module, it works perfectly. But when I try to make the reference, it will only create the DDL for the first of the iterations. I’m testing now in a workspace with 4 different apps and it creates 4 equal DDLs from the first of the items processed.

I’m sure it should be easy but I’m stuck =/

Thank you in advance!

Please share your workflow

Share the output returned by the last node

[
  {
    "id": "chatcmpl-",
    "object": "chat.completion",
    "created": 1729543180,
    "model": "gpt-4o-mini-2024-07-18",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": {
            "result": "CREATE TABLE \"APP_PRUEBA\" (\"id\" bigint NOT NULL AUTO_INCREMENT,\"Título\" varchar(255) DEFAULT NULL,\"Categoría\" varchar(255) DEFAULT NULL,\"Número\" float DEFAULT NULL,PRIMARY KEY (\"id\"))"
          },
          "refusal": null
        },
        "logprobs": null,
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 2293,
      "completion_tokens": 58,
      "total_tokens": 2351,
      "prompt_tokens_details": {
        "cached_tokens": 0
      },
      "completion_tokens_details": {
        "reasoning_tokens": 0
      }
    },
    "system_fingerprint": ""
  },
  {
    "id": "chatcmpl-",
    "object": "chat.completion",
    "created": 1729543181,
    "model": "gpt-4o-mini-2024-07-18",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": {
            "result": "CREATE TABLE APP_PRUEBA (id bigint NOT NULL AUTO_INCREMENT, Título varchar(255) DEFAULT NULL, Categoría varchar(255) DEFAULT NULL, Número float DEFAULT NULL, PRIMARY KEY (id))"
          },
          "refusal": null
        },
        "logprobs": null,
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 2293,
      "completion_tokens": 50,
      "total_tokens": 2343,
      "prompt_tokens_details": {
        "cached_tokens": 2176
      },
      "completion_tokens_details": {
        "reasoning_tokens": 0
      }
    },
    "system_fingerprint": ""
  },
  {
    "id": "chatcmpl-",
    "object": "chat.completion",
    "created": 1729543182,
    "model": "gpt-4o-mini-2024-07-18",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": {
            "result": "CREATE TABLE \"APP_PRUEBA\" (\"id\" bigint NOT NULL AUTO_INCREMENT, \"Título\" varchar(255) DEFAULT NULL, \"Categoría\" varchar(255) DEFAULT NULL, \"Número\" float DEFAULT NULL, PRIMARY KEY (\"id\"))"
          },
          "refusal": null
        },
        "logprobs": null,
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 2293,
      "completion_tokens": 61,
      "total_tokens": 2354,
      "prompt_tokens_details": {
        "cached_tokens": 2176
      },
      "completion_tokens_details": {
        "reasoning_tokens": 0
      }
    },
    "system_fingerprint": ""
  },
  {
    "id": "chatcmpl-",
    "object": "chat.completion",
    "created": 1729543183,
    "model": "gpt-4o-mini-2024-07-18",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": {
            "result": "CREATE TABLE `APP_PRUEBA` (`id` bigint NOT NULL AUTO_INCREMENT, `Título` varchar(255) DEFAULT NULL, `Categoría` varchar(255) DEFAULT NULL, `Número` float DEFAULT NULL, PRIMARY KEY (`id`))"
          },
          "refusal": null
        },
        "logprobs": null,
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 2293,
      "completion_tokens": 59,
      "total_tokens": 2352,
      "prompt_tokens_details": {
        "cached_tokens": 2176
      },
      "completion_tokens_details": {
        "reasoning_tokens": 0
      }
    },
    "system_fingerprint": ""
  }
]

Information on your n8n setup

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

hello @ValPro

you should use the variable as {{ $('get_app').item.json }} or {{ $json }} (if it is the previous node) to refer each item of the get_app node

Thank you @barn4k I tried both but it’s still not working. I got the same output =(

Any other things to try? Would it help to post here the JSONs?

Try to encode the json:
{{ JSON.stringify($('get_app').item.json) }}

1 Like

That works! Thank you so much!!! @barn4k

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