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
- Perform these steps in your browser.
- Use a URL from the table.
- Select Token authentication.
- Paste the user token you want to log on with.
- 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
|