With this Hublify Flows Function you can ...
- make outbound HTTP-Calls
- Type POST / GET / PUT
- Dynamically set data or values for ...
- POST Vars
- GET Vars
- HTTP Header
- Internally the standard curl library is used.
- Retrieve response data and store it as Hublify Flow Variables to work with that data!
Configuration
Yet to come, ... but here a sneak preview:
- [url] - string The url to call (is superReplaced)
- [method] - string "POST|GET|PUT"
- [datamapper_label] - string
- [datamapper_map] - array/object
- => [dataPOST] - array (is superReplaced)
- => [dataGet] - array
- => [dataHeader] - array (is superReplaced)
- [connectionTimeOut] - optional, e.g. "5" sec.
- [timeOut] - optional, e.g. "30" sec.
- [logLvl] - optional, "0 | 1 | 2" for level logged details to action-log.
- [result_type] - string "JSON" or "STRING"
- [hpeTargetVar] - string Name of Flow Variable where to store the result-object of this call. If not given the result will be discarded.
Write it in notation: <scope>::<var-name-path>.
E.g.: local::my.path.to.Variable - [result_datamapper_map] - array|object Optional Hfy-Datamapper-Map applied to the result-data. Of course only, if the result-data-type is an array|object.
Result Handling
You can get the returned data / string of the web-call and store it in a Flow Variable. It is only stored, if you provide hpeTargetVar!
The stored result is always a result-object containing the following properties:
{ 'http_code' - integer The HTTP-Response-Code, e.g.: 200, 404, ... 'error_code' - string Curl error code, 0 = OK 'error_msg' - string Curl error message, if code != 0. 'result' - string|array|object This is the actual result-data received! 'result_type' - string|null Either "JSON" or "STRING" 'duration' - integer Duration of the web-hook-call }
Examples
#1 - "datamapper_map"
In the following example config you can see, the mapped variables & values from data => dataHeader & dataPOST.
"datamapper_map"
{ "map": [ { "src": "data.pos_name", "trg": "url", "conversion": [ { "function": "mapValue", "params": { "mapping": { "Demo Channel": "https://my.webhook-url.xy/", "onDefault": null } } } ] }, { "src": null, "trg": "dataHeader.X-A-REMOTE-TOKEN", "conversion": [ { "function": "set_value", "params": "xy-aSuperSecuRe!cryptedTokenForYourHedda" } ] }, { "src": "data.orderid", "trg": "dataPOST.data.orderid" }, { "src": "data.o_orderid_external", "trg": "dataPOST.data.o_orderid_external" }, { "src": "data.personid", "trg": "dataPOST.data.personid" }, { "src": "data.order_state_code", "trg": "dataPOST.data.order_state_code" }, { "src": "data.order_state_name", "trg": "dataPOST.data.order_state_name" }, { "src": "data.delivery_list", "trg": "dataPOST.data.delivery_list" } ] }