# Calling an external service and receiving the Response in a variable?

**URL:** <https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445>\
**Category:** Developers\
**Tags:** app, tools\
**Created:** [April 29, 2019, 4:36pm UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445 "2019-04-29T16:36:27Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![Erik](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erik/32/9865_2.png) [@Erik](https://community.homey.app/u/Erik)\
**Post date:** [May 4, 2019, 7:40am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/13 "2019-05-04T07:40:59Z")

</div>

Hi all,

Sorry for this delayed response, but I had to find some time for it.  
There are several ways to build the flows @Jef_van_Leeuwen requested.  
Because he wants to map multiple values from the same HTTP response it’s best to make 2 flows with combine cards _GET JSON trigger object (A24)_, _JSON object (T81)_ and _JSONpath Better Logic (A80)_.  
(Native Homey logic support is in development, but for now we rely on BetterLogic for storing variables).

When in doubt validate your JSON values for flow cards with [jsonlint.com](http://jsonlint.com/). Check your JSONpath expressions with [jsonpath.com](http://jsonpath.com/). If you’re using JSONpath expressions on XML responses, be aware of the XML to JSON conversion. This conversion can be simulated on [RunKit.com](https://runkit.com/585436e8fcbda700135741a7/586d421e08e18e001389a004) with the xml2js module.

The first flow will do a get request. The returned response will be available in the JSON token on the trigger of the second flow.  
In the second flow this JSON token can be used in the action cards, where the desired value is queried by JSONpath and put in Better Logic variables.

Preparation - Define Better Logic variables:  
 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/a/ad81eaf607f3af80ebfac58e24a16a884032051f.png)

Flow 1 - Request (poll every hour):  
 ![2019-04-30%2020_05_06-Homey%20Flow](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/e/e5d19a28286ffe0435b83b89570de937e7b4cf55.png)

Flow 2 - Extract values and map to Better Logic:  
Flow 1 triggers this flow because of the matching trigger-name ‘MonitorUpdate’

 ![2019-04-30%2020_06_03-Homey%20Flow](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/5/567d32b2e9c0ceb26cf91878cf552da93a583fef.png)

---

_[View the full topic](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445)._
