Help with hhtp request of this string please


My electricity provider is updating their system and now has an updated API for requests.

Can someone tell me how to use the HTTP node to generate this request please ?

curl -X 'GET' \
  '' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer psk_xxxxxx6b226189e3'


Some more info from onging testing


I have placed a function node in front of the HTTP request and tried almost all the permutations i can find on the forum through searching

The flow below is what produced the error above

[{"id":"6028717e.571d7","type":"inject","z":"88029ce.abbab6","name":"Check Prices","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"300","topic":"","payload":"","payloadType":"date","x":230,"y":500,"wires":[["416043a5.94179c"]]},{"id":"416043a5.94179c","type":"function","z":"88029ce.abbab6","name":"set headers and change Postcode here","func":"//msg.headers = {};\n//msg.headers ['Content-Type'] = 'application / json';\n//msg.headers ['Authorization:Bearer'] = 'psk_16cdf04f4b778a8f0647d66b226189e3';\n\n//return msg;\n\n\nmsg.headers = {\n    Authorization: \"Bearer=\"+\"psk_16cdf04f4b778a8f0647d66b226189e3\"\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":440,"wires":[["a2b6857.bc69078"]]},{"id":"a2b6857.bc69078","type":"http request","z":"88029ce.abbab6","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":540,"wires":[["72c15da3.67bcb4","d0ebe41a.dbc338","d0c5c476.41e9f8","9394e281.e1baa","3ebe8a6.c2cc776","fd55653d.254eb8","f766f49b.2c2868"]]},{"id":"72c15da3.67bcb4","type":"debug","z":"88029ce.abbab6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":520,"wires":[]}]


I tried this "best guess" :stuck_out_tongue:

[{"id":"eb24dc68.9c1cf","type":"http request","z":"cba4f1e8.ceff1","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"  -H accept: application/json  -H Authorization: Bearer psk_xxxxxx6b226189e3","tls":"","persist":false,"proxy":"","authType":"","x":370,"y":200,"wires":[["51e350ec.63821"]]}]

And received this response... which makes sense with your redacted passkey...

{"message":"Missing Authentication Token"}

thanks for the quick response but still not working

I have put my key in (and indeed the post below has it in there as i will just generate a replacement as soon as we get this working)

[{"id":"6028717e.571d7","type":"inject","z":"88029ce.abbab6","name":"Check Prices","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"300","topic":"","payload":"","payloadType":"date","x":190,"y":260,"wires":[["eb24dc68.9c1cf"]]},{"id":"eb24dc68.9c1cf","type":"http request","z":"88029ce.abbab6","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"  -H accept: application/json  -H Authorization: Bearer psk_16cdf04f4b778a8f0647d66b226189e3","tls":"","persist":false,"proxy":"","authType":"","x":310,"y":140,"wires":[["658c369e.f17898"]]},{"id":"658c369e.f17898","type":"debug","z":"88029ce.abbab6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":140,"wires":[]}]

And here is what i get back - tried various permutations with utf, changing from get to post etc - no difference


OK, there is a bearer passkey option in the http request node...

[{"id":"eb24dc68.9c1cf","type":"http request","z":"cba4f1e8.ceff1","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":" -H accept: application/json","tls":"","persist":false,"proxy":"","authType":"bearer","x":370,"y":200,"wires":[["51e350ec.63821"]]}]

That seems to work better as this was the response (and no idea what it means, but it doesn't seem to be an error response):


Sorry, yes, I tested it with your actual token displayed above :innocent:

No worries - thanks again for the quick response

WIll test now and advise


DId you just paste the API key in their with the PSK bit in the front - because i am getting an error when i do that ?

or did you have to put more in there as well as the API (it gets blanked out when exported)


Yes.. the whole psk_16cdf04f4b778a8f0647d66b226189e3

but I, of course, removed it from the URL, which was: -H accept: application/json

You can try importing the flow I posted above as it was exactly what I tested.

Hmm, I now get an error. Perhaps it is a one shot passkey? I have no idea what it is for, just saw an interesting question :slight_smile:

Yeah i did import your flow - and then pasted the API key back in with the psk in front in the bearer key section (as it removes it when you export it)

Definitely not a one shot passkey

WIll keep trying


This is the error i get now


Looking at that error message it looks like it is saying it wants

Bearer=psk_xxxxx (i.e.with the equal sign)

But not sure how to put that in there ?



I think that is just a red herring due other items in the URL... apparently the one I tested that seemed to work only contained the base URL and the authentication, dispite my posted screenshot... I thought I had grabbed the wrong screenshot so had redone it with the rest of the -H accept: application/json in it... but when recreating it, it seems that is what is throwing the error.

I have no idea what -H 'accept: application/json' means or if it is needed in this following method.

But this flow gives consistent results... whether that result is what you are expecting or not is beyond me :smiley:

Flow (with token psk_16cdf04f4b778a8f0647d66b226189e3)

[{"id":"eb24dc68.9c1cf","type":"http request","z":"cba4f1e8.ceff1","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"bearer","x":370,"y":200,"wires":[["44492918.7e7138"]]},{"id":"7d73f41a.97481c","type":"inject","z":"cba4f1e8.ceff1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":200,"wires":[["eb24dc68.9c1cf"]]},{"id":"44492918.7e7138","type":"debug","z":"cba4f1e8.ceff1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":200,"wires":[]}]


Yep that got it - thanks for hanging in there on this one !!

I tend to over think these things rather than just trying the simplest first !

That is correct what it is returning. I will now change the API code


1 Like

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