Profit REST Service UpdateConnector
An external application can use an UpdateConnector to add, change or delete records in the Profit database (options vary per connector). You can only call UpdateConnectors that have been activated in the App connector.
Contents |
Available connectors
You view all GetConnectors and UpdateConnectors that are available for the Profit REST Services (these are the connectors that have been activated in the App connector).
To view available GetConnectors and UpdateConnectors:
- Call the Profit REST Services.
- Use the URL in /metainfo.
- Click on: GET.
You see a list with all available connectors.
View UpdateConnector meta info
You can retrieve a list with the name, the description and all the fields of an UpdateConnector. In the field list, you see the field name, type, length, etc.
To view meta info:
- Call the Profit REST Services.
- Select a connector.
- Use the URL in /metainfo/update/.
Special characters
You must provide special characters (e.g. é, ü, ï) in the UTF-8 format. If you do not, Profit will show a question mark instead of, for example, é, ü or ï.
Note:
This topic is only intended for JSON. For XML, view this topic.
For Windows Powershell, you use the -ContentType 'application/json;charset=utf-8'.] parameter for a Invoke-WebRequest.
Example:
In this example the description of a dossier item is changed:
$token = '<token><version>1</version><data>12345678901234567890123456789012345678901234567890</data></token>'
$encodedToken = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($token))
$authValue = "AfasToken $encodedToken"
$Headers = @{
Authorization = $authValue
}
$url = 'https://12345.afasonlineconnector.nl/profitrestservices/connectors/KnSubject'
$file = '{
"KnSubject": {
"Element": {
"@SbId": 1957,
"Fields": {
"Ds": " öndèrwérp aziëlaan JSON"
}
}
}
}'
Invoke-WebRequest -Uri $url -ContentType 'application/json;charset=utf-8' -Method PUT -Headers $AuthHeaders -Body $file
Run an UpdateConnector
An external application can use an UpdateConnector to add, change or delete records in the Profit database (options vary per connector). You can only call UpdateConnectors that have been activated in the App connector.
Use one of these methods:
- POST: add data (INSERT)
- PUT: change data (UPDATE)
- DELETE: delete data
For REST you cannot to add and change data in one combined call. You can do this using XML, if the UpdateConnector is suitable for this purpose.
To run an UpdateConnector using the tool:
- Call the Profit REST Services.
- Select a connector for the correct method. The URL is displayed.
- Click on the action button to the right of the URL.
- Complete the fields. Mandatory fields are marked with an asterisk.
- Click on: Execute.
- You see the JSON code and the result of the call:
PUT code example
$token = '<token><version>1</version><data>5DEFA8EC26234BB2993040350BDAB18754DB8AF8484301AD1C6CB7BBA20AC16D</data></token>'
$encodedToken = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($token))
$authValue = "AfasToken $encodedToken"
$Headers = @{
Authorization = $authValue
}
$url = 'https://https://server.enyoi.com/Profitrestservices/connectors/KnSubject'
$file = '{
"KnSubject": {
"Element": {
"@SbId": 9769,
"Fields": {
"Ds": "Gewijzigd onderwerp JSON"
}
}
}
}'
Invoke-WebRequest -Uri $url -ContentType application/json -Method PUT -Headers $Headers -Body $file
POST code example
$token = '<token><version>1</version><data>5DEFA8EC26234BB2993040350BDAB18754DB8AF8484301AD1C6CB7BBA20AC16D</data></token>'
$encodedToken = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($token))
$authValue = "AfasToken $encodedToken"
$Headers = @{
Authorization = $authValue
}
$url = 'https://server.enyoi.com/Profitrestservices/connectors/KnSubject'
$file = '{
"KnSubject": {
"Element": {
"@SbId": 2,
"Fields": {
"StId": 2,
"Ds": "Uitgaande telefoongesprek",
"St": true,
"SbBl": true
},
"Objects": {
"KnSubjectLink": {
"Element": {
"@SbId": 2,
"Fields": {
"SfTp": 3,
"SfId": "666"
}
}
}
}
}
}
}'
Invoke-WebRequest -Uri $url -ContentType application/json -Method POST -Headers $Headers -Body $file
DELETE code example
$token = '<token><version>1</version><data>5DEFA8EC26234BB2993040350BDAB18754DB8AF8484301AD1C6CB7BBA20AC16D</data></token>'
$encodedToken = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($token))
$authValue = "AfasToken $encodedToken"
$Headers = @{
Authorization = $authValue
}
$url = 'https://https://server.enyoi.com/Profitrestservices/connectors/KnSubject/KnSubject/@SbId/2'