In some cases, you might want to get the response of an HTTP request step as a file instead of directly to context. For example, when the step returns:
An amount of data that exceeds the output size limit.
Non-textual, binary content, such as an image, PDF, executable file, etc.
Supported Steps
You can return the response as a file for the following steps:
Send an HTTP Request step
Any step that you can Switch to HTTP Mode
Get the HTTP Response as a File
In the step Properties tab, expand the Execution Options section.
Set the Return Response as File option to Yes.
HTTP Request Output
The HTTP request output is a JSON object.
{ "api_object": {
"content_type": "application/json; charset=utf-8",
"filename": "get",
"hashes": {
"md5": "15fff2b2e51d41a12247a0ea1639ee0f",
"sha1": "9f22dac8bd5bb6aecf6c12cb88ee4cee1e18f465",
"sha256": "94feff555d530e167f5cc0715760fce4c39baf258409b781ddd01fa9cf284f1a" },
"size": 351,
"url": "tqfile://steps/e1d63123-d938-46c3-bd5d-51ef9c26c123" } }
Once you get the response, you can access the data using the file URL as input for other steps, such as Run jq Command or Extract all using a regex group/pattern.
The response file is available for 24 hours.
To access a file URL with the format
tqfile://steps/XXXXXXXXX
in a subsequent step, use the file inline function:{{file <JSONPath to the URL>}}
. For example:{{ file $.send_an_http_request.api_object.url }}
. The file inline function isn't required if the file URL is a shareable link.
The hash values can be used to scan online threat databases to ensure the file is safe.
The ContentType is derived from the HTTP response header. The file content type, name, and size (in bytes) can be filter criteria in subsequent workflow steps.
Shareable Links
File URLs with the format tqfile://steps/XXXXXXXXX
can only be used in Torq steps and aren't shareable with third parties. To get a shareable link, set the Shareable Link toggle to Yes. The Shareable Link toggle is only visible when the Return Response As File toggle is set to Yes.
A shareable link will have the format https://link.torq.io/ ***dEjnLCXnv7
, and it can be accessed directly in a subsequent step (it doesn't require the file inline function).
Large Output
If the HTTP response exceeds the size limit, the step will fail or disrupt the workflow run. If your step fails for this reason or you expect the step to return a large response, you should set the Return Response as File parameter to Yes.
The output you'll get is the response file object. Below are examples of extracting information from the HTTP response file.
Extract Using Regex
The Extract all using a regex pattern step will return every match of the regular expression foo*
in the HTTP response file. You can also use the Extract all using a regex group step.
Extract Using JQ
The Run jq Command step will return the parameter [.args]
value in the HTTP response file. To use JQ, you need prior knowledge of the JSON structure.