Hello !
I created a following flow:
After the split node i use the change node where i want use the payload values as url parameters to make new API request. My change node:
My split node output debug console:
I have made some mistakes in setting url parameters because debug node after change node shows that i set the url parameter not correctly.
How to set url parmetes correctly using the payload data to form correct url to make API requests.
The expected correct url example where is msg.paylod.id value in url:
https://localhost:4000/api/v1/clients/ee-dev:COM:10057662:ekukseireklient/tls-certificates
I would be very pleased if some one help what kind of mistake i have made in change node
Lauri-Alo Adamson
laurialo:
Does not work in a change node, you could paste it directly in the url field in the http request node
or in a change node use a JSONata expression eg.
[{"id":"d0885246.b8e748","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"\"https://localhost:4000/api/v1/clients/\" & payload.id & \"/tls-certificates\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":3080,"wires":[[]]}]
"https://localhost:4000/api/v1/clients/" & payload.id & "/tls-certificates"
The change node does not do mustache rendering. however, you can enter the URL with mustache syntax in the http request node directly.
Alternatively, you can use a function node or JSONata in a change node to set up msg.url
.
Also...
↑ you have msg twice (this will end up msg.msg.headers.Auth...
)
Sadly i'm new in this world and this jsonata is not very familiar to me - how can use it.
This function node looks more understandable for example something like :
msg.url = 'https://localhost:4000/api/v1/clients/ <msg.payload.id>/tls-certificates'
return msg;
Only trick how to insert set url with this msg.payload.id to form this url ?
msg.url = "https://localhost:4000/api/v1/clients/" + msg.payload.id + "/tls-certificates";
in a function node. But you are using a change node so it would be simpler there and no extra node needed. But you may do it anyway you wish.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.