Here is  a working code snippet showing how to use Aris (Enterprise Version 10SR19 )  Rest API. 

I had to perform numerous searchs to make it work, I guess this may be useful to others.

Note 

  •  the user runnnig the script must have Aris Api license rigths
  •  the script is written in Microsoft Powershell V5 . Invoke-RestMethod is similar to curl + Json handling

 

$serverUrl="https://arisserver/"
$tokenURL = $serverUrl + "umc/api/v2/tokens"
# ----------------------------
# Get authentication token
# ----------------------------
$body = @{"tenant"="default"; "name"= "username";"password"="userpassword";}
$response = Invoke-RestMethod -Body $Body -Method Post  $tokenURL
$token =  $response.token
# ----------------------------
# Create a session to store the authentication token into a cookie 
# The cookie will be passed along in the below API calls . 
# ----------------------------
# The coookie name must be "accesstoken"
# this is not documented in Aris document ARIS REPOSITORY API TECHNICAL INTRODUCTION" , august 2022
# ----------------------------
$session = [Microsoft.PowerShell.Commands.WebRequestSession]::new()
$cookie = [System.Net.Cookie]::new('accesstoken', $response.token)
$session.Cookies.Add($serverUrl, $cookie)
# ----------------------------
# Now let's make some API Calls
# ----------------------------
# Get list of databases
$arisAPI = "abs/api/"
$getDatabaseURL = $serverUrl + $arisAPI +"databases" 
$response2 = Invoke-RestMethod  -Method Get -WebSession $session $getDatabaseURL
# Use results, for example : $response2.item_count is the number of databases
# Get list of users
$getUsersURL = $serverUrl + "/umc/api/users" 
# pass on parameters
$body = @{"offset"=0; "limit"= 5}
$response3 = Invoke-RestMethod  -Body $body -Method Get -WebSession $session $getUsersURL
# download a document file from Aris data storage (ADS) and save it to PC's desktop
$docId = "xxx-xxxx-xxx-x" #get the id from the doc properties in ADS
$docURL = $serverUrl+"documents/api/documents/"+$docId+"/content"
$localFile="C:\Users\xxxx\Desktop\testADS.xlsx"
$response4 = Invoke-RestMethod  -Method Get -WebSession $session -Outfile $localFile $docURL 
# ----------------------------
# logout , revoke the authentication token
# ----------------------------
$logoutURL = $serverUrl + "umc/api/tokens/"+$token
$response5 = Invoke-RestMethod  -Method Delete -WebSession $session $logoutURL

 or register to reply.

Notify Moderator