REST GET/Post should allow for conditional parameters

As an example:

In the above case depending on how I trigger the pipeline, the from/until parameters of the REST Get call may or may not contain values. Currently, this causes a problem because the underlying API I’m calling with the REST Get balks when from/until are set to blank strings vs not being passed at all. Snaplogic should provide me a way to say if there isn’t an actual value present don’t pass the parameter. As it stands now I have to have all these routes through the pipelines to cover the cases where parameters may or may not be set which has lead to a brittle pipeline construction.

@mike.korcynski for the query parameters in question, you could use an expression for the Service URL that includes them if their values are non-null, and then use the “Query parameters” table for those that should always be present e.g.

And you can see the results of these two requests here:

1 Like

Thanks, @robin hadn’t thought of that. Although, those expressions can start to look convoluted with multiple ternary operators. I’ll make this change though as its better than what I’m doing now, but it’d be nice to not sacrifice readability and the self-documenting nature of the pipeline.

@mike.korcynski, you’re welcome. Also, forgot to mention that the query parameter values in that expression should be encoded e.g. encodeURIComponent($missing) rather than just $missing

Mike - another thing we also can do is to build the query string in a
previous mapper and use the service url expression as

: $url + $queryString

querystring: ?key1=val1&key2=val2&…

Hope that makes sense. You will have much more control on the querystring
variable in the mapper or whichever snap you use to develop that.

Thanks & Regards,


one more suggestion as well.

You can also use ‘https://%s/%s/%s?%s&%s’.sprintf($Host, $Service, $operation, keyparam1, keyparam2 )

This gives you a lot of ability in controlling the order of the URL formation.