INSERT INTO slack_channels (user_id, channel_id, channel_name, created_at)
VALUES ('{{$json["user_id"]}}', '{{$json["channel_id"]}}', '{{$json["channel_name"]}}', NOW())
ON CONFLICT (user_id, channel_id)
DO UPDATE SET channel_name = EXCLUDED.channel_name, created_at = EXCLUDED.created_at;
error – invalid input syntax for type uuid: “{{$json[“user_id”]}}”
n8n version: 1.91.3 (Cloud)
Problem: I’m passing the values dynamically to the postgress node even i can see the values but when I test the flow I got the above mentioned error. I tried to hardcode the values in quotes then it is working fine. Please help me fix this issue
When using Raw query in the SQL node in n8n, if you write the variable interpolation with quotes (like '{{$json["user_id"]}}'
), the value is sent to PostgreSQL as a string. However, if the field expects a UUID type, this will cause an error because a string is not a valid UUID format.
Don’t use quotes: For fields expecting a UUID or other non-string types, do not wrap the interpolated value in quotes.
I tried without quotes as well but no success. I think variables defined in the query parameters are not connected with the query itself. Because i can see the values inside the query parameters and when i test the node it returns uuid null. Not sure what’s going on. I’ve setup a set node before the postgress node and I’ve the set the variables as well
Use direct interpolation and make sure the value comes in the correct format (such as a valid UUID) within the JSON.
I’ve a separate node just before the postgress, where i have set the variables like this
{
“user_id”: “{{ $node[‘Set Credentials’].json[‘user_id’] }}”,
“channel_id”: “{{ $json[‘id’] }}”,
“channel_name”: “{{ $json[‘name’] }}”
}
now I can see those values by clicking on query parameter and then results but still the issue persists. If you need some additional info please let me know i can provide that. Thanks
1 Like
dont u need to use `` and not ‘’ for interpolation?
look what i am doing wrong here i am getting the values from previous node, and it’s been visible in query parameters results as well but still user_id is being passed null
Any suggestion pls
If it serves as a reference, this is how I used variables that come from the JSON in the queries.
with the following structure, example: ‘{{ $json.output.user_id}}’