Link to table field in n8n

Hey Baserowers!

I’m having an issue linking to records inside a “link to table” field inside my table when using the Baserow module in n8n. Perhaps there is a bug or perhaps I am missing something but it’s eluding me entirely at this point.

I have the following example json data that I am trying to send to my Baserow table.

[
    {
        "bedrag": 1718,
        "bieder": "9970185247",
        "datum": "03-04-2024, 20:43",
        "gebruikerId": 403346,
        "land": "NL",
        "id": [
            3828723
        ]
    },
    {
        "bedrag": 1678,
        "bieder": "de Rooy metalen ",
        "datum": "03-04-2024, 20:41",
        "gebruikerId": 460845,
        "land": "NL",
        "id": [
            3828633
        ]
    }
]

I have set up the id as an array as I believe that is what is expected from Baserow’s API.

However, when I map this to the Baserow node as {{ $json.id }} it is being shown in n8n’s preview as [Array: [3828723]]

image

For some reason and if I execute this node, the “link to table” field remains unpopulated and indeed in the response, I see it come through as

"kavelData.id": [ ]

If I try and change the value to {{ $json.id[0] }} to send only the id number 3828723,

image

I end up getting an error returned:


{ "error": "ERROR_REQUEST_BODY_VALIDATION", "detail": { "field_1990805": [ { "error": "Expected a list of items but got type \"int\".", "code": "not_a_list" } ] } }

At this point, I am really not sure where it is going wrong. Any tips appreciated.

Hi,

I think the Baserow node ‘Create a row’ expects a link to table field to contain the id of the table. So, you need to check if 3828723 and 3828633 match with the row id of the corresponding items.

Hey Fredereik :wave: thanks for the quick respose

Yes those ids do exist and should match. I have done some subsequent playing around with this and noticed that if I send multiple values inside the array, it works. So is it the case that the Baserow node simply doesn’t accept a single value in the array? :thinking:

EDIT

I cannot work out what is happening anymore. Now I am sending just a single value in the array on my test base and it is working as intended. But for my main db, the exact same code is not working, even though architecturally, they are basically identical. I’m stumped. :man_shrugging:

I remember that I had a similar issue in n8n once. However, I am not sure if I was using the default HTTP request node or a Baserow node.

I was able to solve the problem by using {{ [$json.id ]}} instead of {{ $json.id }}

That’s a neat trick to make an array of it quickly. However, making it an array is not my problem anymore as that trick still has the same result. I’m just completely stumped now as to why it works on one database but not on the other.

@joffcom could you check this out please :pray:

I am out at the moment but I will take a look at this tomorrow morning.

What version of n8n are you running @cwinhall and are you self hosting baserow or using cloud / managed?

So I’ve managed to reduce the test case down a bit to try and understand what is happening. I will continue to debug this but this is where I am at now: n8n - ▶️ My workflow 5 - 6 April 2024 | Loom

EDIT

Ok so after making a discovery I think I understand what is happening now. I just don’t understand why it is happening :upside_down_face: n8n - ▶️ My workflow 5 - 6 April 2024 | Loom

I’ve worked it out. :man_facepalming:

Should have read the API docs more clearly on creating related rows.

Accepts an array containing the identifiers or main field text values of the related rows from table id 279028.

I was sending the identifier as a number and not as a string (text value). Changed it to a string and now it links the fields correctly.