Robot Input

Most robots executed through the API will be parameterized through input, such as a search keyword, or login credentials. Input to a robot is part of the request to RoboServer and is provided using the createInputVariable method on the request. Let us look at a short code fragment.

Request request = new Request("Library:/Input.robot");
request.createInputVariable("userLogin").setAttribute("username", "scott").setAttribute("password", "tiger");

Input using implicit RQLObjectBuilder

Here we create a Request and use createInputVariable to create an input variable named userLogin. We then use setAttribute to configure the username and password attributes of the input variable.

The above example is a common shorthand notation, but can also be expressed move verbosely by using the RQLObjectBuilder:

Request request = new Request("Library:/Input.robot");
RQLObjectBuilder userLogin = request.createInputVariable("userLogin");
userLogin.setAttribute("username", "scott");
userLogin.setAttribute("password", "tiger");

Input using explicit RQLObjectBuilder

The two examples are identical. The first utilizes the cascading method invocation on the anonymous RQLObjectBuilder is therefore shorter.

When RoboServer receives this request the following occurs:

If a robot requires multiple input variables, you must create all of them in order to execute the robot. You only have to configure required attributes, any no-required attributes that you don't configure through the API will just have a null value. If we assume you have a robot that requires login to both Facebook and Twitter, you could define the input like this.

Request request = new Request("Library:/Input.robot");
request.createInputVariable("facebook").setAttribute("username", "scott").setAttribute("password", "facebook123");
request.createInputVariable("twitter").setAttribute("username", "scott").setAttribute("password", "twitter123");