Extract data from Airly app with URL GET method


#1

1) Give a description of the problem
I cannot extract data about the air quality from a sensor around my home.

2) What is the expected behaviour?
I want to extract data regarding the air quality around my home from Airly app, using their API REST method.I want to use the CAQI index to automate my Air Purifier.When the CAQI index it’s greater than a value, my Air Purifier should turn on for a specified time.
After I will extract the needed data from Aliry i want to pass the CAQI value into a WebCore Variable (i would also need help with this one).

3) What is happening/not happening?
I am still strugelling on making the GET request via WebCore.
First, I’ve tested the Airly API using Postman and it’s working very fine.
When passing the info into WebCore i cannot get it to authenticate.
Here are the API request to be made:

curl -X GET
–header ‘Accept: application/json’
–header 'apikey: myAPIkey
https://airapi.airly.eu/v2/measurements/installation?installationId=204

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
3/11/2020, 4:38:13 PM +651ms
+1ms ╔Received event [Acăsică].test = 1583937493647 with a delay of 4ms
+69ms ║RunTime Analysis CS > 20ms > PS > 35ms > PE > 14ms > CE
+72ms ║Runtime (38212 bytes) successfully initialized in 35ms (v0.3.110.20191009) (70ms)
+73ms ║╔Execution stage started
+78ms ║║Cancelling statement #1’s schedules…
+109ms ║║Sending external web request to: airapi.airly.eu/v2/measurements/installation?installationId=6088
+156ms ║║Error executing external web request: groovyx.net.http.HttpResponseException: Unauthorized
+157ms ║║Executed virtual command httpRequest (66ms)
+162ms ║╚Execution stage complete. (89ms)
+164ms ╚Event processed successfully (164ms)

Thank you,
Vlad


#2

Have you tried sending the key included in the url?

Add the key to the end of your current url in the format:
&apikey=…

*You would not need to pass any other arguements in the get request

You might also want to block out your API Key for future posts, not sure if there is sensitive information to be retrieved but it’s a good habit…


#3

This may help:


#4

Hello,

Thank you for you answers! I’ve managed to extract the data with the information from the post above ( @orangebucket) .

Now I need your support to move on with my small project. :smiley:

This is how my piston looks now:


I need to extract the “Caqi Index Value” and pass in into a variable, which I hope I know how to use it further.

Can you help me with that?

Thank you again,
Vlad


#5

I believe that:
$response.current.indexes.value
will return that data for you…


Notice that this method does not need to mess with Headers.


#6

And this solves my problem!

Thank you very much!