In order to call an API you will need to have an authorization token. A user with admin rights can generate an authorization token.

In the header of your script you need to add the authorization token, below you will see a snipped of a Power-Shell code in which the authorization token is passed to the AP in order to retrieve data.

Each organization will have its own API id, so it is important to know the right ID.

The pattern for the URL is:


A part of the code, in which the AFAS Connector is called


$body =@{





$headers = @{

    Authorization = $token


# The First 100

$destinationFile = 'C:\temp\Afas_test.csv'

$url = ""

try {

           $response = Invoke-RestMethod -Uri $url -method GET -Headers $headers -Body $body

$response.rows | Select-Object *  | Export-Csv  $destinationFile -Delimiter ';' -NoTypeInformation


catch {

           # Dig into the exception to get the Response details.

           # Note that value__ is not a typo.

           Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__

           Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription


#Get the last transaction

$Transaction_ID = Import-CSV $destinationFile -Delimiter ';' | select -ExpandProperty Journaalpost

#Count the transactions

$count = 0

foreach($line in $Transaction_ID)


    if($line -ne ""){$count++}


write-host $count