Parameters are variables that you can use to pass inputs dynamically when invoking Pipelines. Parameter values remain unchanged during Pipeline execution. When defined, these values can be of the Pipeline and are especially useful in parent-child Pconstruct. Passing Pipeline arguments as parameters allow a Pipeline to be reused in multiple situations; this reuse can especially be when creating Tasks from Pipelines. You can also append a query string to the URL with the pairs of the parameters defined in the Pipeline properties.
Passing Arguments through Pipeline Parameters
To pass arguments to the Pipeline:
- In SnapLogic Designer, click to display the Edit Pipeline dialog.
Under Parameters, Add the parameter in the Key field, then define it in the Value field.
The Value specified for a given Key in the Pipeline Parameters that are set from the Pipeline Settings dialog overrides the Value defined in the individual Snaps that make up the Pipeline.
If you a Task named pipeline-with-args, which a Pipeline that the parameters Age and Name, the end of the URLlooks like the following :
You should that you are using in the query string.
Passing Pipeline Parameters in the Semantic URL Form
You can send Pipeline parameters to Triggered Tasks in the semantic URL form. When the Parameter Key is defined in the Pipeline Settings, the Parameter Value is rendered into a variable name. example, if the variable name is PATH_INFO, then it must be defined as a parameter value in the Pipeline itself. In the following example, we add the following parameters:
You can now append the trigger-URL with the new values:
Where the Pipeline parameters are:
- PATH_INFO= newvariable1/newvariable2
Request Pipeline Arguments
You can pass information from the HTTP request to the Trigger Task URL automatically as an argument when the Pipeline is executed. The following arguments are available with names similar to what you might find in a CGI script:
- PATH_INFO—The path elements after the Task part of the URL.
- REMOTE_USER—The name of the user that invoked this request.
- REMOTE_ADDR—The IP address of the host that invoked this request.
- REQUEST_METHOD—The method used to invoke this request.
- QUERY_PARAM—The query string element of the URL that made the request.
- REMOTE_PORT—The port of the client that made the request.
When referencing these arguments, they must be prefixed with an underscore like any other parameter. When designing a Pipeline, you might find it easier to explicitly add these parameters with a default value.
The following HTTP headers from the request might also be available:
You can pass a custom HTTP header by specifying a header and its value through the parameter fields in Pipeline Settings. The request matches any header with Pipeline arguments and passes those to the Task, while the Authorization header is never passed to the Pipeline.
- The header must be capitalized in its entirety. Headers are case-sensitive.
- Hyphens must be changed to underscores.
- The HTTP custom headers override both the Task and Pipeline parameters, but the query string parameter has highest precedence.
For example, if you pass a tenant ID (X-TENANT-ID) in a header, add the parameter X_TENANT_ID and provide a default or leave it blank. When you configure the expression, refer to the Pipeline argument following standard convention: _X_TENANT_ID. In the HTTP request, you add the header
X-TENANT-ID: 123abc, which results in the value 123abc being substituted for the Pipeline argument X_TENANT_ID.
Custom response headers are supported for Ultra Task or Triggered tasks invoked using Ground URLs. They are not supported for Cloud invoked Triggered tasks.
You can set an HTTP header in a Triggered Task by using the Mapper Snap.
To set the header, add a Mapper Snap to the end of the Pipeline.
The Mapper Snap should have a binary output view. To change the output view, click on the View tab, then change the Type of the Output to Binary using the dropdown. Any expressions mapped in the Mapper Snap are now added as an HTTP response header.
The following response shows the endpoint information for the Task URL, where X-My-Header is the custom header being set by the Task:
HTTP/1.1 200 OK
Accept: application/json, /;q=0.5
Date: Wed, 10 June 2020 18:10:00 GMT
X-SL-PolicyOrdering: [com-snaplogic-common-jaxrs-apipolicyinterceptor$sessionauthenticator, com-snaplogic-common-jaxrs-apipolicyinterceptor$snaplogicauthenticator, com-snaplogic-common-jaxrs-apipolicyinterceptor$authsentinel]