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 with multi-part data (as from a html input form):

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

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");