Test Data Webhook – Form Dynamic URL with IF and Switch Macro

Prev Next

Overview

This article explains how to form dynamic Test Data Webhook URLs based on the test that is pushing the data. This is useful in scenarios where the data pushed from certain tests need to be sent over to one endpoint and others to a separate endpoint. This can be done dynamically by using macros to assign specific values on the fly.

We have added support for the if, switch and testid macros to the URL section of Test Data Webhooks.
blobid1.png

Syntax and Examples

Syntax for ${switch} macro:
${Switch(key, case1, value1, case2, value2..N)}

Example using ${testid} to form dynamic URL with ${switch} macro:

https://${switch("${testid}","1884826","enmfvvgl3y0d","1884827","ens76jn94zzo")}.x.pipedream.net

Syntax for ${if} macro:
If(case1, value1, case2, value2, case3, value3, case4, value4... ,caseN ,valueN, valueX)

Example to use ${testid}to form dynamic URL with ${if}macro:

https://${if("${testid} = 1884826","enmfvvgl3y0d","${testid} = 1884827","ens76jn94zzo")}.x.pipedream.net

These examples are functionally equivalent. When the test with id 1884826 posts to the webhook, the macro will form the URL https://enfvvgl3y02.x.pipedream.net, and when test 1884827 posts to the webhook, the macro returns https://ens76jn94zzo.x.pipedream.net.