Skip to content

HTTP Hook trigger

One of the supported triggers for a Skybear.NET Script is the HTTP Hook trigger. You can create an HTTP Hook trigger from the script details page, under the Settings tab. Find all your scripts in the dashboard UI.

HTTP Hook Trigger settings tab

The HTTP Hook trigger is a globally unique URL that upon receiving a POST request runs the script’s Hurl source files.

For example, assume that script s_n0GF2xxjv0X86dLL3HLBm8N has the following HTTP Hook trigger:

https://api.skybear.net/v1/integrations/triggers/http/s_n0GF2xxjv0X86dLL3HLBm8N/strig_http_lvfJk32b9qpk7gsD54HmpjbM2wxkTK82p:sync

The following curl command will trigger a run of the script s_n0GF2xxjv0X86dLL3HLBm8N:

Terminal window
curl -X 'POST' https://api.skybear.net/v1/integrations/triggers/http/s_n0GF2xxjv0X86dLL3HLBm8N/strig_http_lvfJk32b9qpk7gsD54HmpjbM2wxkTK82p:sync

The output of the above command will look something like below:

{
"errorStatus": { "codename": "OK", "message": "script run success" },
"id": "sr_k2og5g5DmtFuecazQYUIf1GyVXeP",
"scriptId": "s_n0GF2xxjv0X86dLL3HLBm8N",
"runStatus": "complete.pass",
"runType": "triggerHttp",
"triggerId": "strig_http_lvfJk32b9qpk7gsD54HmpjbM2wxkTK82p",
"createdAt": "2024-11-10T22:41:25.384Z",
"createdBy": "strig_http_lvfJk32b9qpk7gsD54HmpjbM2wxkTK82p",
"scriptRunViewURL": "https://www.skybear.net/s/s_n0GF2xxjv0X86dLL3HLBm8N/runs/sr_k2og5g5DmtFuecazQYUIf1GyVXeP"
}

Visiting the URL of the scriptRunViewURL property will take you to the script run report in the Skybear.NET application UI, where you can inspect every single request and response including headers and bodies, any occurred assertion failures, and the JSON report(s) as generated by Hurl.

The runStatus value of complete.pass indicates that all the script files passed successfully, whereas complete.fail would indicate that even though the Hurl execution completed successfully, something in the script failed (e.g. an assertion).

If the runStatus value is server_error_undefined, then something failed on the Skybear.NET backend and the script did not execute to completion, therefore no report has been generated. In this case, the errorStatus object would contain more information on the failure that you can send to our support email for further investigation.

Execution overrides

Hurl variables

As part of the POST request to the HTTP Hook trigger URL you can provide Hurl variable overrides for the script to use.

Any provided Hurl variable takes precedence over the values of same-named Hurl variables set in the dashboard (see Secrets & Hurl variables).

Hurl source texts

A script created and authored in the Skybear.NET dashboard only has a single Hurl source file. However, the “script” resource can actually contain more than one Hurl source files.

As part of the POST request to the HTTP Hook trigger URL you can provide the source text for the files you want to run in this specific execution, instead of the source text authored in the dashboard.

JSON request

The following Hurl file (named example-json-request.hurl) is an example of how you can send a POST request to the HTTP Hook trigger URL with overrides for both Hurl variables and source files.

POST https://api.skybear.net/v1/integrations/triggers/http/s_n0GF2xxjv0X86dLL3HLBm8N/strig_http_lvfJk32b9qpk7gsD54HmpjbM2wxkTK82p:sync
Content-Type: application/json
{
"hurlVariables": {
"ABOUT_URL": "https://about.skybear.net"
},
"srcTexts": {
"hello.hurl": "GET {{ ABOUT_URL }}\n[Options]\noutput: about.html\nHTTP 301",
"second.hurl": "GET https://skybear.net\nHTTP 301\n\n\n\n# Redirects to www. subdomain.",
"another/with/subdirs/third.hurl": "GET https://www.skybear.net\n[Options]\noutput: www.html\nHTTP 200"
}
}

Running the above Hurl script with hurl example-json-request.hurl will invoke the HTTP Hook trigger URL and the script execution will use the provided value for the Hurl variable BASE_URL, and the Hurl files executed will be the ones provided in the srcTexts property.

The corresponding curl command is as follows:

Terminal window
curl \
--header 'Content-Type: application/json' \
--data $'{"srcTexts": {\n"hello.hurl": "GET {{ ABOUT_URL }}\\n[Options]\\noutput: about.html\\nHTTP 301", "second.hurl": "GET https://skybear.net\\nHTTP 301\\n\\n\\n\\n# Redirects to www. subdomain.", "another/with/subdirs/third.hurl": "GET https://www.skybear.net\\n[Options]\\noutput: www.html\\nHTTP 200"}}' \
'https://api.skybear.net/v1/integrations/triggers/http/s_n0GF2xxjv0X86dLL3HLBm8N/strig_http_lvfJk32b9qpk7gsD54HmpjbM2wxkTK82p:sync'

Multipart FormData request

Apart from JSON, the HTTP Hook trigger supports multipart/form-data requests.

The multipart request can provide a srcTexts[] field that will contain all the source files to run as part of the script execution.

Assume a directory hurl/samples has the following structure:

Terminal window
hurl/samples/
├── get-with-output.hurl
├── ipv6.hurl
├── nested
└── helloworld.hurl
└── simple-get.hurl

We can use the following bash command to find all the *.hurl files in the directory and send them with curl as part of a multipart/form-data request (see curl docs).

Terminal window
find "hurl/samples/" -iname "*.hurl" -print0 \
| xargs -0 printf -- '-F srcTexts[]=@%s\n' \
| tr '\n' ' ' \
| xargs curl -X POST 'https://api.skybear.net/v1/integrations/triggers/http/s_n0GF2xxjv0X86dLL3HLBm8N/strig_http_lvfJk32b9qpk7gsD54HmpjbM2wxkTK82p:sync'

In order to provide Hurl variable overrides you can provide the variables as multipart values with the following curl options:

-F hurlVariables.0.Name=ABOUT_URL -F hurlVariables.0.Val=https://about.skybear.net

So, each variable needs two values, hurlVariables.<index>.Name=<name> for the variable name and hurlVariables.<index>.Val=<value> for the variable value.

You can use up to 100 Hurl variables, including overrides and the ones defined in the account dashboard.