Skip to main content

getViaRest

A Workflow Engine function that performs a GET request to a configured REST endpoint with an optional set of query parameters and stores the response in workflowContext.values.<endpointName>.

This function supports in-memory caching to reduce repeated requests for the same data. Cached entries are time-bound (default: 300 seconds) and limited to 1,000 items. When the limit is reached, the oldest entry is removed using a First In, First Out (FIFO) policy.

Caching is enabled only when both the namespace and key parameters are provided.

  1. The function checks the configured namespace for the specified key.

  2. If a cached entry exists, the cached data is copied to workflowContext.values.<endpointName> as though the request had completed successfully.

  3. If no cached entry exists, the GET request is executed. If successful, the response data is cached in the configured namespace using the specified key.

  4. Cache expiration is determined as follows:

    1. If cacheTTL is configured, that value is used as the cache Time-To-Live (TTL).

    2. If cacheTTL is not configured, a default TTL of 300 seconds (5 minutes) is used.

  5. When cached data is returned, spoofed request and response details are added to the workflow context under the requestStatus and responseCodes.<endpointName> keys, as though the request had completed successfully (for example:).

    {
        "requestStatus": {
            "status": "success",
            "status_code": 200,
            "status_msg": "OK"
        },
        "responseCodes": {
            "testEndpoint": 200
        }
    	...
    }

This function is available as a feature of the Add-ons v2.7 download and later.

This function is available for event, alert, and Situation workflows.

Back to Workflow Engine Functions Reference.

Arguments

Workflow Engine function getViaRest takes the following arguments:

Name

Required

Type

Description

endpointName

yes

string

The name of the REST endpoint configured on the Integrations page (must use the GET protocol).

paramMapName

yes

string

The name of the payload map configured on the Integrations page. The map is used to populate request parameters for the REST endpoint.

urlOverride

no

string

Overrides the configured endpoint URL. This can be used to construct a URL dynamically, for example by using CEvent substitution.

namespace

no

string

The namespace used for caching.

key

no

string

The key used within the caching namespace. This value supports substitution. Avoid using values that vary between CEvents that are expected to use the same cache entry. For example, do not use $(alert_id) as the key, as this creates a separate cache entry for each alert and prevents reuse of cached data.

cacheTTL

no

number

The cache Time-To-Live (TTL) in seconds. The default value is 300 seconds (5 minutes).

getViaRest stores the response data in workflowContext.values.<endpointName>.

Example

The following example demonstrates typical use of Workflow Engine function getViaRest.

The getViaRest function downloads the results under workflowContext.values.<endpointName>. You can use subsequent actions such as:

  • copyFromContext to copy results from workflowContext.values.<endpointName> to cevent.custom_info.<KEY>.

  • mergeList to condense results from different endpoints under single field either workflowContext or custom_info, for example:

    from workflowContext.values.RESTEndpoints1, workflowContext.values.RESTEndpoints2 to workflowContext.values.mergedList

    or,

    from custom_info.enrichment.RESTEndpoints1, custom_info.enrichment.RESTEndpoints2 to custom_info.enrichment.rest

  • reduceObjectsList to reduce a list of similar objects to single object. You can apply this function to either workflowContext or custom_info fields, such as custom_info.enrichment.RESTEndpoints1 or workflowContext.values.RESTEndpoint1.