Ever wonder how to perform HTTP requests from WarpScript? Depending on your needs, here are 3 ways to achieve it.

Often we need to perform HTTP requests in our scripts, for instance, to send a notification in a Slack channel or to a mailing API, to fetch data from a REST API or to send data to a tier server.
In Warp 10 2.x, there was 3 ways to perform HTTP requests in WarpScript or FLoWS.
Update: Since Warp 10 3.0, there is only one way : the HTTP function.
HTTP
HTTP allows you to send a GET or POST HTTP request (thanks Captain Obvious), waiting for a response.
Among the different options, you can even stream your data using the chunks.
Following Warp 10 3.0 trend, most of the configurations can be superseeded by capabilities.
Configuration parameters in /path/to/warp10/etc/conf.d/70--extensions.conf
:
warpscript.extension.http=io.warp10.script.ext.http.HttpWarpScriptExtension
: Activate the extensionwarpscript.http.maxrequests
: maximum parallel usagewarpscript.http.maxsize
: maximum response sizewarpscript.http.maxchunksize
: maximum chunk sizewarpscript.http.host.patterns
: allow/disallow some hosts based on a comma separated list of regular expression likeslack.com,.*!
WarpScript
First, you need to generate a token to be able to use HTTP: create a mc2 file with this content
Run it. By default, TOKENGEN is not accessible, so you need an access to the server to run /opt/warp10/bin/warp10.sh tokengen /path/to/this/file.mc2
Then you can use the generated token in your script with CAPADD
, to enjoy HTTP!
WEBCALL (deprecated)
WEBCALL is historically the first one. It allows you to send an HTTP request without waiting for a response. This is a one-way action. WEBCALL is handy to notify an HTTP Server without slowing your code execution or introducing a bottleneck.
Configuration parameters in /path/to/warp10/etc/conf.d/10-webcall.conf
:
webcall.host.patterns
: allow/disallow some hosts based on regular expression likeslack.com,!^127.0.0.1$,!^localhost$,^192.168.*
warpscript.maxwebcalls
: maximum parallel usagehttp.header.webcall.uuid
: will appear in theX-Warp10-WebCall
headerwebcall.user.agent
: "Warp10-WebCall" by default
WarpScript
URLFETCH (deprecated)
URLFETCH allows you to perform a GET request and give you back the response, headers and status. It could be a bottleneck in your code, because it waits for the response.
For security reasons, you must be authenticated with a READ token.
By the way, this function will be deprecated in a future Warp 10 version because replaced by HTTP
.
Configuration parameters in /path/to/warp10/etc/conf.d/70--extensions.conf
:
warpscript.extension.urlfetch = io.warp10.script.ext.urlfetch.UrlFetchWarpScriptExtension
: Activate the extensionwarpscript.urlfetch.limit
: maximum parallel usage a developer can bypasswarpscript.urlfetch.limit.hard
: maximum parallel usagewarpscript.urlfetch.maxsize
: maximum response size a developer can bypasswarpscript.urlfetch.maxsize.hard
: maximum response sizewarpscript.urlfetch.host.patterns
: allow/disallow some hosts based on regular expression likeslack.com,.*!
WarpScript
Going further
You can now access external APIs and make Warp 10 dialog with your stack.
To simplify your usage, you can develop macros to embed those calls in order to factorize and control your code.
Read more
W. Files Conspiracy vol. 2: Spy drones over UDP
The Py4J plugin for Warp 10
Time series forecasts in WarpScript

Senior Software Engineer