Skip to content

HTTP

The Http module enables http requests to be sent within a flow.

GET

Send a HTTP GET request. Returns a reply object containing;

  • status the http status-code
  • data a string containing the data received
  • headers an object containing the headers received
  • toDisk is a method to write the response data to disk

Parameters

  • url the url to GET
  • opts options, an object which may contain the following properties:
    • credentials (optional) for basic-auth - an object containing;
      • auth set to "basic" for basic auth
      • username username for the http resource
      • password password for the http resource
    • headers (optional) an object defining headers to include in the request
    • useragent (optional) a string overriding the default user agent
    • timeout (optional, default 60000) ms to wait for the request to complete
    • contenttype (optional) the requests content type
    • accept (optional) an Accept header
    • host (optional) the Host header
    • useWebRequest (optional, default false) whether to use the .NET built-in http-client
    • useWindowsAuth (optional, default false) use NTML authorization with current users credentials
    • cookies (optional, default null) an object containing cookies to send with the request

Example

javascript
// Anonymous
var reply = Http.get("http://somewhere/over/the/rainbow.txt", {});
if (reply.status == 200)  { // Status: OK
  ...
}
// With basic-auth user/pass
Http.get("http://somewhere/over/the/rainbow.txt", { 'credentials': { 'auth': 'basic', 'username': 'John', 'password': 'ramb0' } });

POST

Send a HTTP POST request. Returns a reply object containing;

  • status the http status-code
  • data a string containing the data received

Parameters

  • url the url to POST to
  • data a string to POST
  • opts options, an object containing addition options for the request (see description in Http.get)

Example

javascript
// Anonymous
var reply = Http.post("http://somewhere/over/the/rainbow.txt", "data=123", {});
if (reply.status == 200)  { // Status: OK
  ...
}

To include some tasty cookies with your POST request:

javascript
var reply = Http.post("http://somewhere/over/the/rainbow.txt", "data=123", {
  cookies: {
    cookie1: "value1",
    cookie2: "value2",
  },
});

PUT

Send a HTTP PUT request. Returns a reply object containing;

  • status the http status-code
  • data a string containing the data received

Parameters

  • url the url to PUT to
  • data a string to PUT
  • opts options, an object containing options for the request (see description in Http.get)

Example

javascript
// Anonymous
var reply = Http.put("http://somewhere/over/the/rainbow.txt", "data=123" {});
if (reply.status == 200)  { // Status: OK
  ...
}

DELETE

Send a HTTP DELETE request. Returns a reply object containing;

  • status the http status-code
  • data a string containing the data received

Parameters

  • url the url to DELETE
  • opts options, an object containing options for the request (see description in Http.get)

Example

javascript
// Anonymous
var reply = Http.delete("http://somewhere/over/the/rainbow.txt", {});
if (reply.status == 200)  { // Status: OK
  ...
}

Upload a file using a form post

Upload a file using a POST request. Returns a reply object containing:

  • statusthe http status code
  • statusDescription a string describing the status, or null if no error
  • data a string containing the data
  • headersa list of headers returned from the post. In the form of key-value pairs, where the values are list of strings
  • cookieslist of cookies returned from the post
  • errorMessagea message describing the error or null

The options argument can include:

  • multipart (bool) to indicate whether or not to do a multipart upload
  • timeout (int) number of ms to wait for multipart upload to finish
  • headers (object) headers to apply to the request

Example with multi-part data (as from a html input form):

javascript
Http.upload("https://httpbin.org/post", "C:\\Users\\someone\\somefile.txt", {
    multipart: true,
    timeout: 10000,
    headers: { accept: "application/json"}
} );

This returned:

js
{
  "status": 200,
  "statusDescription": "OK",
  "data": "",
  "headers": {
    "Connection": ["keep-alive"],
    "Access-Control-Allow-Origin": ["*"],
    "Access-Control-Allow-Credentials": ["true"],
    "Date": ["Fri, 03 Oct 2025 13:24:41 GMT"],
    "Server": ["gunicorn/19.9.0"]
  },
  "cookies": null,
  "errorMessage": "OK"
}

Please note that behavior would be a bit different if multipart is set to false. For instance the status would be 0 if there where no errors.

In case of an error it is returned in the ´reply´. For instance:

js
{
  "status": 503,
  "statusDescription": "Service Temporarily Unavailable",
  "data": "",
  "headers": {
    "Connection": [
      "keep-alive"
    ],
    "Date": [
      "Fri, 03 Oct 2025 13:08:14 GMT"
    ],
    "Server": [
      "awselb/2.0"
    ]
  },
  "cookies": null,
  "errorMessage": "Service Temporarily Unavailable"
}

Download a file and store it to disk

Download a remote file and store it to a local disk:

js
Http.get("http://save.my/file.txt").toDisk("C:\\here\\is\\my\\file.txt");