Variable in HTTP URL

Hello everyone,

I am trying to change my URL from the HTTP node with some variables.
The range depends on the last two numbers in the URL. I would like to get those values from the date node.
can someone help me please?


[

[{"id":"ced92f11b1ac93e9","type":"ui_date_picker","z":"27cc266ed6fe3207","name":"","label":"Begin datum","group":"772b1b396b59caed","order":1,"width":3,"height":"2","passthru":true,"topic":"topic","topicType":"msg","className":"","x":330,"y":1660,"wires":[["e995284cc644bb76"]]},{"id":"3323423a7ba7bba7","type":"ui_date_picker","z":"27cc266ed6fe3207","name":"","label":"Eind datum","group":"772b1b396b59caed","order":2,"width":3,"height":"2","passthru":true,"topic":"topic","topicType":"msg","className":"","x":330,"y":1700,"wires":[["a007fd8b9c6748ed"]]},{"id":"4bb69eaed3164003","type":"debug","z":"27cc266ed6fe3207","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":910,"y":1660,"wires":[]},{"id":"e995284cc644bb76","type":"function","z":"27cc266ed6fe3207","name":"","func":"//Waarden toekennen\n\nvar BeginDatum = msg.payload\n\n\n//Weergeven in console\nmsg.payload.BeginDatum = BeginDatum\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":1660,"wires":[["4bb69eaed3164003","03514bb389890642"]]},{"id":"ab4e93d77159a4df","type":"inject","z":"27cc266ed6fe3207","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":1680,"wires":[["ced92f11b1ac93e9","3323423a7ba7bba7"]]},{"id":"a007fd8b9c6748ed","type":"function","z":"27cc266ed6fe3207","name":"","func":"//Waarden toekennen\nvar EindDatum = msg.payload\n\n\n//Weergeven in console\nmsg.payload.EindDatum = EindDatum\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":560,"y":1700,"wires":[["4bb69eaed3164003","03514bb389890642"]]},{"id":"03514bb389890642","type":"http request","z":"27cc266ed6fe3207","name":"Laadpaal uitlezen","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://app1pub.smappee.net/dev/v3/chargingparks/59796/sessions?range=1640991600000,1643669940000","tls":"","persist":false,"proxy":"","authType":"bearer","senderr":false,"credentials":{},"x":750,"y":1760,"wires":[["f905ccdb55bd2d80"]]},{"id":"f905ccdb55bd2d80","type":"debug","z":"27cc266ed6fe3207","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":1760,"wires":[]},{"id":"772b1b396b59caed","type":"ui_group","name":"Selecteer onderstaande data","tab":"e6a0e46d81483439","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"e6a0e46d81483439","type":"ui_tab","name":"Laadpalen","icon":"dashboard","order":9,"disabled":false,"hidden":false}]

You can construct the URL outside the http request node and pass it in as msg.url

(You leave the URL in the HTTP request node blank.)

1 Like

Thanks for responding.

I made the url outside of the http node but it still doenst work. do you see what I did wrong?

Thanks in advance
Olivia

Did you leave the URL in the http node empty?

i did leave it empty

I would start by putting a debug node on the output of the node that sets the URL. It's most likely a concatenation issue. (I am not an expert, so I might be wildly wrong!)

EDIT: Just a thought: perhaps start by setting your url to the literal string you showed in your first post. That way you will know whether the value is being accepted.

Hi
When i put the normal url in the function node, it works

when i put the new url in the function node I get errors
this is how the new url looks

You would need to join the function messages, then you can use template or other means to construct the url
e,g.

[{"id":"ab4e93d77159a4df","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":640,"wires":[["ced92f11b1ac93e9","3323423a7ba7bba7"]]},{"id":"ced92f11b1ac93e9","type":"ui_date_picker","z":"bf9e1e33.030598","name":"","label":"Begin datum","group":"772b1b396b59caed","order":1,"width":3,"height":"2","passthru":true,"topic":"begin","topicType":"str","className":"","x":240,"y":540,"wires":[["159c59fe.cc5886"]]},{"id":"3323423a7ba7bba7","type":"ui_date_picker","z":"bf9e1e33.030598","name":"","label":"Eind datum","group":"772b1b396b59caed","order":2,"width":3,"height":"2","passthru":true,"topic":"eind","topicType":"str","className":"","x":240,"y":580,"wires":[["159c59fe.cc5886"]]},{"id":"159c59fe.cc5886","type":"join","z":"bf9e1e33.030598","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":630,"y":560,"wires":[["4bb69eaed3164003","f3e6e4ec.a9fe5"]]},{"id":"4bb69eaed3164003","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":820,"y":540,"wires":[]},{"id":"f3e6e4ec.a9fe5","type":"template","z":"bf9e1e33.030598","name":"","field":"url","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"https://app1pub.smappee.net/dev/v3/chargingparks/59796/sessions?range={{payload.begin}},{{payload.eind}}","output":"str","x":780,"y":600,"wires":[["f905ccdb55bd2d80","03514bb389890642"]]},{"id":"03514bb389890642","type":"http request","z":"bf9e1e33.030598","name":"Laadpaal uitlezen","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"bearer","x":660,"y":640,"wires":[["4bb69eaed3164003"]]},{"id":"f905ccdb55bd2d80","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"url","targetType":"msg","statusVal":"","statusType":"auto","x":980,"y":600,"wires":[]},{"id":"772b1b396b59caed","type":"ui_group","name":"Selecteer onderstaande data","tab":"e6a0e46d81483439","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"e6a0e46d81483439","type":"ui_tab","name":"Laadpalen","icon":"dashboard","order":9,"disabled":false,"hidden":false}]

[edit] infact the function nodes are not needed at all

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