Adding customerID at the end of requisition doesn't work with expression

I am trying to use the following endpoint to get customer data: https://api.trinks.com/v1/clientes/{clienteId}

On Postman, https://api.trinks.com/v1/clientes/24118322 returns the expected customer data.

I tried in n8n using an expression: https://api.trinks.com/v1/clientes/{{ $json[“cliente”] }}. The resulting request appears identical to the one above: https://api.trinks.com/v1/clientes/24118322

But I am getting this error:

Any suggestion?

Information on your n8n setup

  • n8n version: 0.230.3

  • Database (default: SQLite): postgres

  • n8n EXECUTIONS_PROCESS setting (default: own, main): main

  • **Running n8n via (Docker, npm, n8n cloud, desktop app):**docker

  • Operating system: linux

The only thing I can think of is that something on the n8n server on the network side is not setup correctly and not allowing it to make the outbound call. Are you able to use the HTTP request on that instance of n8n for other websites? You can use a service like httpbin.org to see if your calls get out and what your calls look like to the other server. You would need the http request url like this: http://httpbin.org/get instead of your current url. Also turn off your credentials so you don’t send them over.

yes, in general HTTPS requests are working perfectly. In fact, this customer ID is coming from a previous request to another endpoint from the same service:

My first thought is you have 2 items going into the node maybe the second item doesn’t have a customer ID or it is an invalid one, Have you double checked that?

Ah I see the problem, you are referencing the json key that flows into the loop but that one changes so on the second loop the value is not what you expect.

Instead reference the split in batches node for your url ID so that it pulls the current item in the loop instead of whatever json becomes that client id key (which changes every loop). Think of the split in batches loop as the anchor to reference your loops to.

Let me know if this makes sense, if not I can send you a more detailed explanation.

3 Likes

It worked!

I removed the Splitoutitems node and referenced directly the customer ID from the Split in Batches and the request worked without error!

2 Likes

Wonderful! Glad to hear you got it working! Now that you know how to use the split in batches node, the world is your oyster!

2 Likes

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