Fetches data from an external service by calling a connected serviceā€˜s operation and a payload if needed.


json_object service(string $service, string $operation, any $payload)


$service: The name of the connected service in the unit. Read more about connected services and how to create one here.
$operation: The name of the operation in the service.
$payload: Information in the data that can be forwarded with the request in order to specify the request. For operations utilizing GET, the payload must be a flat key/value object.


In the connected service following information is listed:
Name: Forecast (manually typed)
Operation: Weather (manually typed)
Type: GET or POST
URL: The URL to the service, in this case:
Response Type: Unspecified format or JSON format

   //Nothing is needed here when a connected service is used  
    Forecast: service('Forecast', 'Weather', 
        latitude: '55.628648', 
        longitude: '12.589531', 
    "Forecast": {
        "temperatureCelcius": 22.5,
        "temperatureFahrenheit": 72.5,
        "type": "Sunny"

From the documentation of the “Weather” API, we know we can find information about latitude and longitude if we forward keys with some specific numbers as values. To get this information, a flat key/value object is forwarded with the GET request as payload, and using our connected service ‘Forecast’ and the operation (endpoint) Weather, the information is returned from the API.