# Help with hhtp request of this string please

**URL:** <https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557>\
**Category:** General\
**Created:** [24 June 2021 02:47 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557 "2021-06-24T02:47:04Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [24 June 2021 02:47 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/1 "2021-06-24T02:47:04Z")

</div>

Guys,

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 ?

```auto
curl -X 'GET' \
  'https://api.amber.com.au/v1/sites' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer psk_xxxxxx6b226189e3'

```

Craig

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [24 June 2021 03:20 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/2 "2021-06-24T03:20:55Z")

</div>

Some more info from onging testing

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/e/1e215da1d7a91bbeb94438bd38705724c4a1e8d9.png)

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

```auto
[{"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":"https://api.amber.com.au/v1/sites","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":[]}]

```

Craig

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [24 June 2021 03:28 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/3 "2021-06-24T03:28:53Z")

</div>

> [@craigcurtin](#):
>
> ```auto
> 'https://api.amber.com.au/v1/sites' \
> -H 'accept: application/json' \
> -H 'Authorization: Bearer psk_xxxxxx6b226189e3'
> 
> ```

I tried this "best guess" 😛

```auto
[{"id":"eb24dc68.9c1cf","type":"http request","z":"cba4f1e8.ceff1","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://api.amber.com.au/v1/sites -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"}`

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [24 June 2021 03:38 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/4 "2021-06-24T03:38:51Z")

</div>

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)

```auto
[{"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":"https://api.amber.com.au/v1/sites -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

Craig

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/1/a134454bb680ec6b6dd7a671357e157a30a129cf.png)

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [24 June 2021 03:44 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/5 "2021-06-24T03:44:54Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/2/e26ae001f2f0ac3e8f4c007ee77874c675d0de6d.png)

```auto
[{"id":"eb24dc68.9c1cf","type":"http request","z":"cba4f1e8.ceff1","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://api.amber.com.au/v1/sites -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):

`[{"id":"01ECxxxxxxxxxH5SCQAZ0F","nmi":"410xxxxx338","channels":[{"identifier":"B1","type":"feedIn"},{"identifier":"E1","type":"general"}]}]`

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

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [24 June 2021 04:03 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/6 "2021-06-24T04:03:31Z")

</div>

No worries - thanks again for the quick response

WIll test now and advise

Craig

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [24 June 2021 04:08 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/7 "2021-06-24T04:08:05Z")

</div>

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)

Craig

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [24 June 2021 04:12 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/8 "2021-06-24T04:12:28Z")

</div>

> [@craigcurtin](#):
>
> with the PSK bit in the front

Yes.. the whole **psk\_16cdf04f4b778a8f0647d66b226189e3**

but I, of course, removed it from the URL, which was:  
`https://api.amber.com.au/v1/sites -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 🙂

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [24 June 2021 04:39 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/9 "2021-06-24T04:39:53Z")

</div>

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

Craig

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [24 June 2021 04:43 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/10 "2021-06-24T04:43:06Z")

</div>

This is the error i get now

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/4/5476da9669d22afd0bb683906585b63a0608f92f.png)

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 ?

Craig

Craig

---

<div class="post-metadata">

**Author:** ![Gunner](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gunner/32/43582_2.png) [@Gunner](https://discourse.nodered.org/u/Gunner)\
**Post date:** [24 June 2021 06:14 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/11 "2021-06-24T06:14:08Z")

</div>

> [@craigcurtin](#):
>
> Bearer=psk\_xxxxx (i.e.with the equal sign)

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 😃

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/1/d19acffe3844dc07a7b4f7975b0d6088971e4ef1.png)

Flow (with token **psk\_16cdf04f4b778a8f0647d66b226189e3** )

```auto
[{"id":"eb24dc68.9c1cf","type":"http request","z":"cba4f1e8.ceff1","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://api.amber.com.au/v1/sites","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":[]}]

```

Result  
`[{"id":"01EC780K3J6E1SFKAH5SCQAZ0F","nmi":"4103298338","channels":[{"identifier":"B1","type":"feedIn"},{"identifier":"E1","type":"general"}]}]`

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [24 June 2021 06:42 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/12 "2021-06-24T06:42:01Z")

</div>

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

Craig

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 July 2021 06:42 UTC](https://discourse.nodered.org/t/help-with-hhtp-request-of-this-string-please/47557/13 "2021-07-08T06:42:31Z")

</div>

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