# GET request with Headers and output to variable

**URL:** <https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114>\
**Category:** Flows\
**Created:** [September 14, 2019, 12:38pm UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114 "2019-09-14T12:38:50Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![peltsi51](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peltsi51/32/12564_2.png) [@peltsi51](https://community.homey.app/u/peltsi51)\
**Post date:** [September 14, 2019, 12:38pm UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/1 "2019-09-14T12:38:51Z")

</div>

Trying to build a flow that makes the GET request to outside server ([https://api.fingrid.fi/v1/variable/177/event/json](https://api.fingrid.fi/v1/variable/177/event/json)) the request should have a header with api key (x-api-key:xxxyyyzzz) and I would like to get the response value saved to better logic variable.

Can someone point out how this can be made. I used the Homey logic to the request and got it to work with the headers and all, but cannot save it to better logic variable. example below

 ![Screenshot_20190914-153700_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/7/7d769892ac066a72ee968ff68652c6faed6346ae.jpeg)

EDIT:

Got it to work with the HTTP request flow cards - app. In order to get the headers also to the request, you have to use full JSON description in the URL value to input the headers. Below is the example.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/9/9e2b01175fb9d47506a7977669e17c4871ffdbe7.jpeg)

---

<div class="post-metadata">

**Author:** ![elfrigo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/elfrigo/32/7893_2.png) [@elfrigo](https://community.homey.app/u/elfrigo)\
**Post date:** [October 7, 2019, 7:01am UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/2 "2019-10-07T07:01:40Z")

</div>

Thank you for sharing this solution. This is something I would like to use in a slightly different way. Hopefully you can help me in the right direction.  
I use my Synology for Surveillance as a camera hub. Homey detects my family presence and sends a string to turn my presence ON/OFF. For authentication with my Synology I use a SID. You can retrieve this SID with a string. But this SID can change. So I would like to use Homey to automate the SID request URL and use this output as a variable.

- The request URL is: https://[internal IP]:5001/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=[username]&passwd=[password]&session=SurveillanceStation&format=sid

- The output response is:  
{“data”:{“sid”:"[SID]"},“success”:true}

- My question:  
How can I select the output [SID] and use it as a variable? What flow do I need?

Thank you very much for all the help !!

---

<div class="post-metadata">

**Author:** ![peltsi51](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peltsi51/32/12564_2.png) [@peltsi51](https://community.homey.app/u/peltsi51)\
**Post date:** [October 7, 2019, 10:08am UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/3 "2019-10-07T10:08:31Z")

</div>

Hi

You should use the HTTP request flow card “GET JSONpath Better Logic”-actioncard as I stated before.

In order to get the [SID] value into variable, you should use the JSONpath value of $.data.sid -\> and save it to some better logic number variable.

There is some detailed descriuptions of the JSONpath values in here [https://goessner.net/articles/JsonPath/](https://goessner.net/articles/JsonPath/)

Hopefully this helps, if not please feel free to ask.

---

<div class="post-metadata">

**Author:** ![elfrigo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/elfrigo/32/7893_2.png) [@elfrigo](https://community.homey.app/u/elfrigo)\
**Post date:** [October 7, 2019, 7:02pm UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/4 "2019-10-07T19:02:33Z")

</div>

Hi Peltsi, First thank you very much for your help. Second … it works.

I had do make some changes …  
The value of the $.data.sid is numbers+letters so I changed it to a _string_ type variable.  
Also it was bit confusing (probably it just my head) that I can just just that string variable as a “tag” inside an URL of a HTTP request flow card. But … it works 🙂

Now I only need to find out how to have Homey accept a “insecure” https certificate 😇

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [October 7, 2019, 7:26pm UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/5 "2019-10-07T19:26:57Z")

</div>

> [@elfrigo](#):
>
> Now I only need to find out how to have Homey accept a “insecure” https certificate

I don’t think you can ☹

---

<div class="post-metadata">

**Author:** ![Dennis\_van\_Dinter](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dennis_van_dinter/32/28180_2.png) [@Dennis\_van\_Dinter](https://community.homey.app/u/Dennis_van_Dinter)\
**Post date:** [August 12, 2020, 1:14pm UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/6 "2020-08-12T13:14:20Z")

</div>

Hi,

Can anyone tell me how I formulate multiple headers in the url? How do I divide them? Do I use double " around the soapaction, if the soapaction has them at the beginning and end standard?

“headers”:{“SOAPACTION”:"“urn:schemas-sony-com:service:IRCC:1#X\_SendIRCC”"}{“X-Auth-PSK”:“1111”}}

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [August 12, 2020, 1:18pm UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/7 "2020-08-12T13:18:26Z")

</div>

> [@Dennis\_van\_Dinter](#):
>
> Can anyone tell me how I formulate multiple headers in the url?

```auto
"headers":{"SOAPACTION":"urn:schemas-sony-com:service:IRCC:1#X_SendIRCC","X-Auth-PSK":"1111"}

```

---

<div class="post-metadata">

**Author:** ![Dennis\_van\_Dinter](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dennis_van_dinter/32/28180_2.png) [@Dennis\_van\_Dinter](https://community.homey.app/u/Dennis_van_Dinter)\
**Post date:** [August 12, 2020, 1:34pm UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/8 "2020-08-12T13:34:56Z")

</div>

Thank you, Robert for your quick response!!

@Enjoying my new Homey!

---

<div class="post-metadata">

**Author:** ![Dennis\_van\_Dinter](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dennis_van_dinter/32/28180_2.png) [@Dennis\_van\_Dinter](https://community.homey.app/u/Dennis_van_Dinter)\
**Post date:** [August 12, 2020, 2:23pm UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/9 "2020-08-12T14:23:06Z")

</div>

Can you also show me how to formulate this when I am using a Logic web request card?

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [August 12, 2020, 2:47pm UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/10 "2020-08-12T14:47:14Z")

</div>

I believe Logic webcards require you to enter each header line separately, which (AFAIK) is not possible through the mobile Homey app.

It’s possible through the [desktop website](https://flow.homey.app) by hitting Shift-Enter after each header line:  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/7/a77840f951fdb5898ea9f8d2307b5f8e1962ce7f.png)

(I tried in Chrome on macOS, perhaps on Windows or other browsers “Shift” needs to be something else)

---

<div class="post-metadata">

**Author:** ![Dennis\_van\_Dinter](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dennis_van_dinter/32/28180_2.png) [@Dennis\_van\_Dinter](https://community.homey.app/u/Dennis_van_Dinter)\
**Post date:** [August 12, 2020, 2:54pm UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/11 "2020-08-12T14:54:20Z")

</div>

Ok, thank you, will try that tonight!!

I made this in the http request app and used Post Json, but it gives an error: cannot read property of ‘IndexOf’ of null. I put the headers in the url:

{“method”:“post”,“protocol”:“http:”,“hostname”:“192.168.68.60”,“path”:"/sony/ircc",“headers”:{“SOAPACTION”:“urn:schemas-sony-com:service:IRCC:1#X\_SendIRCC”,“X-Auth-PSK”:"1111}}

Body

{\<?xml version="1.0" encoding="utf-8"?\> \<s:Envelope xmlns:s=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)” s:encodingStyle=“[http://schemas.xmlsoap.org/soap/encoding/](http://schemas.xmlsoap.org/soap/encoding/)”\> \<s:Body\> \<u:X\_SendIRCC xmlns:u=“urn:schemas-sony-com:service:IRCC:1”\> AAAAAQAAAAEAAAAVAw== \</u:X\_SendIRCC\> \</s:Body\> \</s:Envelope\>

What am I ding wrong?

Thanx for the help!

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [August 12, 2020, 4:32pm UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/12 "2020-08-12T16:32:35Z")

</div>

You need to use the “POST XML” card, not the “POST JSON” card.

---

<div class="post-metadata">

**Author:** ![erlend\_oyen](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erlend_oyen/32/18133_2.png) [@erlend\_oyen](https://community.homey.app/u/erlend_oyen)\
**Post date:** [November 6, 2021, 7:29am UTC](https://community.homey.app/t/get-request-with-headers-and-output-to-variable/18114/13 "2021-11-06T07:29:13Z")

</div>

UPDATE: managed to get homey script to work 🙂

Hi

i have an similar challenge, i am looking at the Get json better logic card, but i have not been able to get it to work, and the dialog is not the same as in the screenshots in this thread?  
i don’t see the text, text, search field.

i have also played around a bit with homey script, but have not been able to get it to work  
i tested using the output from postman in nodejs.native but it did not work, but i suspect that homey script is different?

the request is simple:

[https://app.ngenic.se/api/v3/tunes/TUNE\_ID/measurements/NODE\_ID/latest?type=temperature\_C](https://app.ngenic.se/api/v3/tunes/TUNE_ID/measurements/NODE_ID/latest?type=temperature_C)

Headers:  
Content-type: application/json  
Authorization: Bearer TOKEN

the request returns

{  
“hasValue”: true,  
“time”: “2021-11-06T07:37:32 Europe/Oslo”,  
“value”: -7.3033294677734375  
}

i wish to take the value and use it in the next action in the flow to update the temperature of a virtual sensor

Thanks!
