REST Endpoints
By installing the Therefore™ BC Connector, the following endpoints are added:
-
TFDocuments
-
ProcessingJournals
Those endpoints are neither part of the OData, nor the v2.0 API of Business central. Depending on your system, they are reachable under those URLs:
https://bcserver:7048/bc/api/therefore/connector/v1.0/tfdocuments
https://bcserver:7048/bc/api/therefore/connector/v1.0/companies(company-id)/tfdocuments
(“tfdocuments” was chosen as a sample endpoint here)
Company-ID:
To find out the company ID, you can call the following API function:
https://api.businesscentral.dynamics.com/v2.0/environment-guid/api/v2.0/companies
https://bcserver:7048/bc/api/v2.0/companies
It is a GET call without a body and requires the same authorization as the other API calls.
Environment-GUID:
To find out your “environment-guid”, click on “? -> Help & Support”
Then scroll down to “Troubleshooting” to find your Azure AD Tenant ID
Installation
If you have trouble reaching one of the Therefore™ endpoints, please ensure that the following settings are turned on:
-
Enable API Service
-
Enable OData Services
Therefore™ Documents
Endpoint: tfdocuments
Supported operations: GET, POST
This endpoint enables access to the Therefore-Documents table, stored in BC. The table contains link between entries in BC and Therefore™ documents. For every document that shows up in the Drop Zone, an entry in this table must exist.
Examples:
-
Check if a Therefore™ document is already to BC
This can be done by sending GET request and applying a filter for “ThereforeDocumentNo”. There is no body required.
https://bcserver:7048/bc/api/therefore/connector/v1.0/tfdocuments?$filter=ThereforeDocumentNo eq 1234 -
Link a Therefore™ document to an object in BC
This can be done by sending a POST request to tfdocuments endpoint.Sample Body:
Copy{
"ThereforeDocumentNo": 1234,
"TableID": 38,
"DocumentType": 2,
"DocumentNo": "4321",
"CategoryNo": 11,
"AdditionalInfo": "Linked with REST",
"Filename": "invoice_4321.pdf"
}
This will create a link between Therefore document number 1234, stored in category 11 and a Purchase Invoice in Business Central (Table 38, type 2). The link will show up in the Drop Zone of the Connector, as invoice_4321.pdf. The AdditionalInfo is an optional comment, visible in the Therefore-Documents table.
Processing Journals
Endpoint: processingjournals
Supported operations: GET, POST
This endpoint reads or creates an entry in the BC connector’s “queue for saving”.
It can be used to schedule a delayed index data update or creation of a document.
Examples:
-
Check if a certain entry for delayed update of index data already exists in the queue for saving. This can be done by sending GET request and applying a filter for “Status” and for “NAVDocumentID”. There is no body required. The value for NAVDocumentID, has to come from the “LinkID” returned by “tfdocuments” REST endpoint.
https://bcserver:7048/bc/api/therefore/connector/v1.0/processingjournals?$filter= Status eq 'delayed update of indexdata' and NAVDocumentID eq 1234 -
Insert an entry into the “queue for saving”, to update index data when posting a purchase invoice. This can be done by sending a POST request to processingjournals endpoint. Sample Body:
Copy{
"DocumentNo": ”1234”,
"NAVDocumentID": 4321,
"TableID": 122,
"CategoryID": 11,
"Status": "delayed update of indexdata"
}
This will create an entry into the “queue for saving”.
The “DocumentNo” 1234 is the invoice of purchase invoice in BC (not posted).
The “TableID” 122 is the posted Purchase Invoice in Business Central, so update will be done, when posting the invoice.
The “CategoryID” 11 is the Therefore™ category ID where the document is stored.
The "NAVDocumentID": 4321 is the “LinkID”, returned by “tfdocuments” REST endpoint.
The "Status" has to be set to "delayed update of indexdata".