Homey Community Forum

GET request with Headers and output to variable

Trying to build a flow that makes the GET request to outside server (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

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.

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 !!

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/

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

1 Like

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 :slight_smile:

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

I don’t think you can :frowning: