In this article
...
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.
Info |
---|
The input data must contain the correct content-type header based on your use case, else your pipeline fails. |
Snap Type
HTTP Routers Snap is a Flow-type Snap that executes HTTP requests.
Prerequisites
None.
Support for Ultra Pipelines
...
Limitations and Known Issues
None.
Snap Views
Input/Output | Type of ViewType | Format | Number of Views | Examples of Upstream and Downstream Snaps | Description |
---|---|---|---|---|---|
Input | Document |
|
| A document containing the data to be processed based on the incoming HTTP request. | |
Output | Document |
|
| 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. | |
Error | Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter while running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:
Learn more about Error handling in Pipelines. |
...
Info |
---|
|
Field Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Label | String |
Default Value: N/A Example: HTTP Router | |||||||||
Routes* | Use this field set to define/map one output view each to one or more of the request methods supported |
. Click to add a new row |
and define the values accordingly. |
This field set comprises of the following fields:
Request method |
Request method
String/Expression/Suggestion | Select or enter one request method |
per |
row, depending on the different HTTP requests expected from the Triggered task. The following different request methods are supported:
This field allows an additional value OTHER to handle request methods coming from the Triggered Task that are not configured in this Snap. Default Value: N/A | ||
Output view name | Dropdown list | Select an output view name from this |
dropdown list 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 |
overview image |
is routed to output4 that corresponds to the value OTHER.
|
|
Default Value: N/A | |||
Snap Execution | Dropdown list | Select one of the three following modes in which the Snap executes:
Default Value: Validate & Execute |
Troubleshooting
Error | Reason | Resolution |
---|---|---|
Failed to evaluate expression: _ |
Request_Method. | The expression for the Request Method field contains an invalid |
pipeline parameter and the Snap |
cannot process the incoming requests. | Ensure |
you use the correct spelling for |
pipeline parameters within the expressions defined in Snap's settings. | ||
If your data contains invalid content-type headers or if you pass an incorrect JSON payload, the Snap aborts the pipeline with an error. | When the Snap receives an invalid content-type header in the input, the error appears at the platform level and therefore is not displayed in the Snap Settings dialogue box. | Ensure to pass valid JSON Payload and content-type headers. |
Examples
Using HTTP Router Snap to Process the Request from a Triggered Task
The following example Pipeline 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 Task | Pipeline 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 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.
...
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.
Using HTTP Router Snap to Process an Ultra Task
The following example Pipeline 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 pipeline with a request to send a notification to the patchadmin@snaplogic.com whenever a patch is completed.
Ultra Task for HTTP Router Snap | Pipeline with HTTP Router Snap |
---|---|
We configure the HTTP Router Snap to route incoming data to the 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 Using the File Writer Snap, you can further write the formatted JSON output into a JSON file using the File Writer Snap.
Downloads
Multiexcerpt include macro | ||||
---|---|---|---|---|
|
...
Related Links
- Getting started with SnapLogic SnapLogic Product Glossary
- Snap Support for Ultra Pipelines