In this article

Overview

Use this Snap to route documents to output views based on the incoming HTTP request method. This Snap is primarily meant for use in Pipelines executed through Triggered Tasks. The Snap matches the HTTP request method used in the Triggered Task and routes the document to the corresponding output view as configured for the request method.

Prerequisites

None.

Support for Ultra Pipelines

Works in Ultra Pipelines.

Limitations and Known Issues

None.

Snap Input and Output

Input/OutputType of ViewNumber of ViewsExamples of Upstream and Downstream SnapsDescription 
Input 

Document

  • Min: 1
  • Max: 1
  • Mapper Snap
  • Copy Snap
  • JSON Generator
A document containing the data to be processed based on the incoming HTTP request. 
Output

Document

  • Min: 1
  • Max: ∞
  • Mapper Snap
  • Union Snap
  • JSON Formatter

If the input document is routed to more than one output views, they are all instances of the same input document. The Pipeline may fail if any downstream Snap attempts to modify the same document without copying it.

Snap Settings

Parameter NameData TypeDescriptionDefault ValueExample 
LabelString
N/AHTTP Router

Routes

Required. Use this field set to define/map one output view each to one or more of the request methods supportedOnly one method can be specified in each row. Click  to add a new row in this table and define the values accordingly. 

This field set comprises of the following fields:

  • Request method
  • Output view name

Request method

String/Expression/Suggestion

Select or enter one request method, per each row, depending on the different HTTP requests expected from the Triggered task. The following different request methods are supported:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE
  • HEAD

This field allows an additional value OTHER to handle request methods coming from the Triggered Task that are not configured in this Snap.

N/AGET

Output view name

Drop-down list

Select an output view name from this drop-down list for each Request method selected. 

Map the value OTHER to an output view that suits your exception handling requirements. For example, an incoming request method DELETE or HEAD in the above scenario (image) is routed to output4 that corresponds to the value OTHER.

Ensure that the required number of output views are added for the Snap from the Views tab. These output views will, then, be listed in this field for you to select.


N/Aoutput3
Snap ExecutionDrop-down list

Select one of the three following modes in which the Snap executes:

  • Validate & Execute. Performs limited execution of the Snap and generates a data preview during Pipeline validation, then performs full execution of the Snap (unlimited records) during Pipeline runtime.
  • Execute only. Performs full execution of the Snap during Pipeline execution without generating preview data.
  • Disabled. Disables the Snap and all Snaps downstream from it.

Validate & ExecuteExecute only

Troubleshooting

ErrorReasonResolution
Failed to evaluate expression: _Reqest_Method.The expression for the Request Method field contains an invalid Pipeline parameter and the Snap is unable to process the incoming requests.

Ensure that you use the correct spelling for Pipeline parameters within the expressions defined in Snap's settings.

Examples

Using HTTP Router Snap to Process the Request from a Triggered Task

The following example Pipeline demonstrates the use of HTTP Router Snap to process an incoming POST request via a Triggered Task. This Pipeline contains the REQUEST_METHOD parameter configured with the value POST.

Triggered TaskPipeline with HTTP Router Snap

Pipeline Properties

When the Triggered Task - Task_On_HTTP_Router is run from the Task's details page, the corresponding Pipeline is executed.

The HTTP Router is configured to route the incoming document to a corresponding output view, matching the Request method value with the REQUEST_METHOD Pipeline parameter.

HTTP Router Snap SettingsHTTP Router Snap Views

In this example, the HTTP Router uses this JSON document and the REQUEST_METHOD from the Triggered Task as inputs. Based on the incoming value for REQUEST_METHOD (POST in this example), the HTTP Router routes the document to the corresponding output view (output1 in the validated Pipeline above). The Pipeline execution continues further to finally write the formatted JSON output into a JSON file.

Download this Pipeline

Using HTTP Router Snap to Process an Ultra Task

The following example Pipeline demonstrates how you can use an HTTP Router Snap to process an incoming PATCH request through an Ultra Task. 

First, we create an Ultra Task for the HTTP Router Pipeline with a request to send a notification to the patchadmin@snaplogic.com whenever a patch is completed.

Ultra Task for HTTP Router SnapPipeline with HTTP Router Snap

We configure the HTTP Router Snap to route the incoming data to a corresponding view.

When the Ultra Task - Ultra_Task_On_HTTP_Router is run, the corresponding Pipeline - HTTP Router is executed. Based on the HTTP method, the HTTP router routes the data to the corresponding output view (in this example, the patch request routes to output 4). You can further write the formatted JSON output into a JSON file using the File Writer Snap.

Download this Pipeline.

Downloads

  1. Download and import the Pipeline into SnapLogic.
  2. Provide Pipeline parameters as applicable.

Edit the Excerpt Include macro below to link to the Snap Pack page for this Snap page. Ensure that the heading Snap Pack History is not within the Snap Pack's history Excerpt. 


See Also