The REST package has been deprecated as of Xill IDE version 3.1. It has been replaced by the XURL package.

REST is used to execute one of the four CRUD (Create, Read, Update and Delete) actions towards online content. In REST these four actions are:

  • post
  • get
  • put
  • delete
This tutorial is going to show you how to use Xill IDE to perform the POST and GET actions. So let's start by using the POST method. As told before, the POST method is used to create a new item. You might use this function to import new pages into a Web based Content Management System like AEM (Adobe Experience Manager). Then you would use the, options, body) function. Attached to this solution, is an example of a uploaded page for AEM. See the temporary.json file.
use File, REST, String, System;

var filename = "C:/tmp/temporary.json";
if(File.exists(filename)) {
	var body = REST.bodyCreate();
	var loc = "//testlocation.html";

	REST.bodyAddFile(body, ":contentFile", filename);
	REST.bodyAddText(body, ":operation", "import");
	REST.bodyAddText(body, ":contentType", "json");

	REST.bodyAddText(body, ":replace", "true");
	REST.bodyAddText(body, ":replaceProperties", "true");
	REST.bodyAddText(body, ":name", itemName);

	var target_folder = "http://localhost:4502" :: loc;
	System.print("Uploading: " :: filename :: " to " :: parentPath);
	var response ="http://localhost:4502" :: parentPath, {"user" : "admin", "pass" : "admin"}, body);

	if(String.contains(response, "<div id=\"Status\">201</div>")) {
		// Success, no further logging required
	} else {
		var message = String.replace(response, "^.*?<div id=\"Message\">(.*?)</div>.*", "$1");
		if(message != null) {
			System.print(message, "warning");

The GET method is used to retrieve/read information. In this example, we are going to query Google for "Xillio" and print out the links with their introduction texts. Let's start by executing the search on Google.  

use REST;

var page = REST.get("", {});

The page variable is an object which now holds information about the REST execution. If there were errors during the execution, page.errors will be a filled object with all the errors at the index page.errors. If the execution was successful, the errors index will be empty and the page.body index will be filled with the output of the REST method. We will save the output to a local temporary file with the following code: 

var f = File.openWrite("C:/tmp/google_results.html");
File.write(page.body, f);

Next we will load the temporary local file into the page variable, so that we can use the Web.xPath() function to use specific parts of the retrieved HTML. This is where we also define a counter and a global variable for the href of every link in the search results:  

var href = "";
page = Web.loadPage("file:///C:/tmp/google_results.html");

 Now we will loop through all the search results: 

foreach(item in Web.xPath(page, "//div[@class='g']")) {
	href = Web.xPath(item, "./h3/a/@href"); // Retrieve the uncleaned url
	var text = Web.xPath(item, "./h3/a/text()"); // Retrieve the introduction text

Let's clean up the href and output the results per link:

href = String.replace(href, "file:\\/\\/\\/url\\?q\\=", ""); // Step 1 of cleaning url: replace the local url with the globally accessable url
href = String.replace(href, "(.*)&sa(.*)", "$1"); // Step 2: Remove every unnessecary extra arguments
System.print("Text: " :: text);
System.print("href:" :: href);

The entire robot is also attached to this solution with the name "RESTget.xill".