Profit REST Service FileConnector
Profit Connector for uploading and downloading files.
Contents |
Retrieve a file from Profit
You need the GUID and the original file name of the attachment. These can be retrieved with a GetConnector. Next, call the FileConnector and retrieve the file.
You can only use the FileConnector to retrieve files if the SubjectConnector has been activated in the app connector.
Retrieve GUID and file name using a GetConnector
- Go to: General / Output / Management / GetConnector.
- Click on: New.
- Add a GetConnector based on a data collection with dossier items.
- Change the data collection and add the following fields:
- Code (GUID of the attachment)
- Name (Original file name of the attachment)
To retrieve a file using the connector:
- Call the Profit REST Services.
- Call:
https://{Domain}/ProfitRestServices/fileconnector/{GUID}/{filename}
Example:
../ProfitRestServices/fileconnector/F64BB8E942BBC5E94FC747904E19FE1B/Invoice3734.pdf
The file name must be the original name that you have retrieved from Profit. So you cannot invent a name.
If the file name of an attachment contains an underscore (_), replace it with _5f.
For example: You replace file name Invoice_nr3734.pdf with Invoice_5fnr3734.pdf.
- Choose one of the following methods to save the file:
- Base64 string
- Original file format with the original file name (Binary)
Upload a file to Profit
You can only use the FileConnector to upload files if the correct UpdateConnector has been activated in the app connector. Use a suitable UpdateConnector, such as KnSubject.
This process consists of two steps:
- Upload the file. The file is assigned a GUID.
- Link the GUID to an existing dossier item.
Step 1: To upload a file:
- In the test tool, drag the file into the Drop files here box.
- Click on: Upload files.
You can see the GUID below the box.
In a script, you can upload the file using the following call:
..ProfitRestServices/fileconnector/knsubject/[binary_filename]
Step 2: To link a GUID to a dossier item:
In this example you add a dossier item with an attachment. You must provide the original file name of the attachment and the GUID.
"KnSubject": {
"Element": {
"@SbId": 2,
"Fields": {
"StId": 4,
"Ds": "Invoice received from AFAS",
"SbPa": "Invoice12345.pdf",
"FileId": "7FF06DEF4743C61A7D595BAB68B6B55A"
},
"Objects": {
"KnSubjectLink": {
"Element": {
"@SbId": 2,
"Fields": {
"ToBC": true,
"BcId": "1001074"
}
}
}
}
}
}
}