Hi I found a way to use http requests in ARIS script, this solution uses JAVA methods but it works fine with our ARIS setup. The code below is a GET request.
function httpRequest(url){ var obj = new java.net.URL(url); var con = obj.openConnection(); con.setRequestMethod("GET"); con.setRequestProperty("User-Agent", java.net.USER_AGENT); var responseCode = con.getResponseCode(); var iN = new java.io.BufferedReader(new java.io.InputStreamReader(con.getInputStream())); var inputLine = new java.lang.String(); var response = new java.lang.StringBuffer(); while((inputLine = iN.readLine()) != null){ response.append(inputLine); } iN.close(); return new java.lang.String(response); }
This method returns a String with the response body (html code). You can later parse the response and use in your own script.
You can also use authorization if you need by adding this lines to the method.
var encoding = new java.lang.String(org.apache.commons.codec.binary.Base64().encodeBase64(userpass.getBytes())); con.setRequestProperty("Authorization", "Basic " + encoding);
Note: The user and password (userpass variable) needs to be in the format username:password for basic authorization.
If you tries to connect to a webserver that don't exists or gives no response you need to use try catch statement to prevent script errors.
try{ // statments that can cause errors like // con.getResponseCode(), con.getInputStream()))... } catch(e){ // handle error }
Yes, ARIS RESTful API first needs a token provided by ARIS Server after a login:
http://localhost/apidocs/swagger-ui/index.html?url=/umc/apidocs/swagger.json#!/tokens/login
But the above article is about the ARIS Script API which is completely different from ARIS Document Storage API.
While the ARIS ADS (RESTful) API is an meant for EXTERNAL access/outside ARIS, the ARIS Script API is used by report scripts running INSIDE an ARIS Server.
Cheers
Rune