Call a connector using the Profit REST Service

An external application calls a connector on the basis of a token.

To view the endpoints, see Endpoints for Profit Connectors (SOAP/XML and REST/JSON).

Contents

Call a Connector using a test tool

  1. Perform these steps in your browser.
  2. Use a URL from the table.
  3. Select Token authentication.
  4. Paste the user token you want to log on with.

  5. Click on: Login.

    If the login is successful, a page appears showing the available calls for GetConnectors, UpdateConnectors, etc.

Examples of code for calling a connector

These examples have been created with Windows PowerShell. AFAS does not provide support for this part. In the call, the token must be converted to a base64 string.

To call a GetConnector:

$token = '<token><version>1</version><data>0E6824699F40129E254DB96441233E32F13454355184E5A24F8E3C0DFA4F</data></token>'

$encodedToken = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($token))

$authValue = "AfasToken $encodedToken"

$Headers = @{

Authorization = $authValue

}

$url = 'https://server.domain.nl/Profitrestservices/connectors/Profit_Article'

$file = '\\yourserver\volume\folder\Getconnector.json'

Invoke-WebRequest -Uri $url -OutFile $file -Headers $Headers

To retrieve meta info:

$token = '<token><version>1</version><data>0E6824612043AA9E254DB961223DD33E32F14943D93184E5A234553C0DFA4F</data></token>'

$encodedToken = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($token))

$authValue = "AfasToken $encodedToken"

$Headers = @{

Authorization = $authValue

}

Invoke-WebRequest -Uri 'https://[webserver.com]/Profitrestservices//metainfo' -Headers $Headers

Directly to

  1. Profit Rest Services (JSON)
  2. Call a connector using the Profit REST Service
  3. Add an app connector for the Profit REST Service
  4. Generate a token for the Profit REST Service
  5. Convert XML to JSON
  6. Call a GetConnector
  7. Call an UpdateConnector
  8. Call a ReportConnector
  9. Call a SubjectConnector
  10. Call a ProfitVersionConnector