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-codedata
a string containing the data receivedheaders
an object containing the headers receivedtoDisk
is a method to write the response data to disk
Parameters
url
the url to GETopts
options, an object which may contain the following properties:credentials
(optional) for basic-auth - an object containing;auth
set to"basic"
for basic authusername
username for the http resourcepassword
password for the http resource
headers
(optional) an object defining headers to include in the requestuseragent
(optional) a string overriding the default user agenttimeout
(optional, default60000
) ms to wait for the request to completecontenttype
(optional) the requests content typeaccept
(optional) an Accept headerhost
(optional) the Host headeruseWebRequest
(optional, defaultfalse
) whether to use the .NET built-in http-clientuseWindowsAuth
(optional, defaultfalse
) use NTML authorization with current users credentialscookies
(optional, defaultnull
) 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-codedata
a string containing the data received
Parameters
url
the url to POST todata
a string to POSTopts
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-codedata
a string containing the data received
Parameters
url
the url to PUT todata
a string to PUTopts
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-codedata
a string containing the data received
Parameters
url
the url to DELETEopts
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");