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 should be set to "basic" for basic-auth
      • username username for the http resource
      • password password for the http resource
    • headers (optional) an object defining additional headers to include in the request
    • useragent (optional) a string overriding the default useragent
    • timeout (optional, default 60000) how many ms to wait for the request to complete
    • contenttype (optional) the contenttype of the request
    • 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

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 additation 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
  ...
}

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 additation 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 additation 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

Downloading a remote file and storing it to a local disk can be done like:

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