Drafts Scripting Reference

HTTP

The HTTP and HTTPResponse objects are used to run synchronous HTTP requests to communicate with APIs, or just read pages from the web. A full set of custom settings can be passed, and all HTTP methods (GET, POST, PUT, DELETE, etc.) are supported.

Instance Functions

Class Functions

Examples

var http = HTTP.create(); // create HTTP object

var response = http.request({
  "url": "http://myurl.com/api",
  "method": "POST",
  "data": {
    "key":"value"
  },
  "headers": {
    "HeaderName": "HeaderValue"
  }
});

if (response.success) {
  var text = response.responseText;
  var data = response.responseData;
}
else {
  console.log(response.statusCode);
  console.log(response.error);
}