Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

...

ErrorReasonResolution
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

...

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 incoming data to the corresponding view.
Image Modified

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). Using the File Writer Snap, you can further write the formatted JSON output into a JSON file.

Download this Pipeline.

Downloads

Multiexcerpt include macro
namedownload_instructions
pageOpenAPI

...