REST extension
Plugin ID
The plugin ID for REST API is fr.cantor.c4i.RESTDelivery.
Properties
Environment independent parameters (set in extension configuration or properties file)
| Property key | Description | Mandatory | Default value |
|---|---|---|---|
| configAssetId | The ID of the asset containing the YAML mappings | Yes | |
| connection | The name of the connection in the c4i.properties file | Yes | |
| isKeyInURL | true to send each object in a single request with the object ID in the URL, false otherwise. Use {id} in URL template | Yes | |
| batchSize | The maximum number of elements to send in a single query | Yes | |
| authenticationMode | NONE, BASIC_AUTH, API_KEY_TOKEN, API_KEY_BEARER, X_API_KEY, OAUTH2_CLIENT_CREDENTIALS or CUSTOM_TOKEN | No | NONE |
| contentType | Content-Type header value. Authorized values are APPLICATION_JSON (application/json) and TEXT_PLAIN (text/plain;charset=UTF-8) | Yes | |
| outputFormat | CSV, EXCEL, JSON, JSONL, XML or XMLL | Yes | |
| headers.{headerName} | Any additional header to send in the HTTP call. See section "Headers templating" for more info | No | |
| lastBatchHeader | If a value is provided, then the last batch for an object type will have this value as a header. It may produce an additional REST call with an empty body | No | |
| cacheConfig | The ID of the asset containing the JCS configuration | No | |
| displayPerfStat | true to display performance statistics (see Performance statistics dedicated page) | No | false |
Environment dependent parameters (set in centralized c4i.properties file)
| Property key | Description | Mandatory | Default value |
|---|---|---|---|
| destinationURL | URL of the target REST API. See section "URL templating" for more info | Yes | |
| authenticationMode | NONE, BASIC_AUTH, API_KEY_TOKEN, API_KEY_BEARER, X_API_KEY, OAUTH2_CLIENT_CREDENTIALS or CUSTOM_TOKEN | No | NONE |
| username | The username (Basic Auth) or Client ID (OAuth2) | No | |
| password | The password (Basic Auth), API Key or Client Secret (OAuth2) in standalone mode only | No | |
| readTimeout | The maximum time of inactivity between two data packets when waiting for the server's response in seconds | No | |
| oAuth2TokenEndpoint | The endpoint to retrieve the OAuth2 token | If authenticationMode is OAUTH2_CLIENT_CREDENTIALS or CUSTOM_TOKEN | |
| oAuth2Scope | The OAuth2 token scope | No | |
| loginQueryScript | The Asset ID/File path of the script to use to build the custom token call | If authenticationMode is CUSTOM_TOKEN | |
| tokenExtractorScript | The Asset ID/File path of the script to use to extract the token from the custom token call response | If authenticationMode is CUSTOM_TOKEN | |
| tokenHeaders.{headerName} | Any additional header to send in the custom HTTP token request call. | No |
Notes
All HTTP queries are performed using the POST method.
Configuration example
extensions.[0].pluginId=fr.cantor.c4i.RESTDelivery
extensions.[0].isKeyInURL=true
extensions.[0].batchSize=100
extensions.[0].outputFormat=JSON
extensions.[0].configAssetId=C4I-Configuration
extensions.[0].additionalHeader1=Execution-Id: {uuid}
extensions.[0].additionalHeader2=MyHeader: Value
extensions.[0].contentType=APPLICATION_JSON
extensions.[0].lastBatchHeader=Last-Batch= true
pluginId=fr.cantor.c4i.RESTDelivery
batchSize=100
outputFormat=JSON
configAssetId=/Path/to/C4I/Configuration.yml
additionalHeader1=Execution-Id: {uuid}
additionalHeader2=MyHeader: Value
contentType=APPLICATION_JSON
lastBatchHeader=Last-Batch= true
licenseAssetId=/Path/to/C4I/License.cat
cacheConfig=/Path/to/JCS/Config.ccf
destinationURL=http://my-web-server.com
username=c4i
password=client_secret
authenticationMethod=OAUTH2_CLIENT_CREDENTIALS
oAuth2TokenEndpoint=https://my-oauth2-endpoint.com/auth/realms/myrealm/protocol/openid-connect/token
oAuth2Scope=my-custom-scope
readTimeout=10
URL templating
The target URL can be templated with :
- Context ID using the variable
{contextId} - Destination name from YAML configuration file using the variable
{destination} - Object ID using the variable
{id}
For instance, given the following URL tempate : http://my-web-server.com/{destination}?lang={contextId},
And using the following YAML configuration file :
- Product:
products[id]:
...
- Entity:
entities[id]:
...
While parsing a file in the context fr_FR,
Products will be sent to the following URL : http://my-web-server.com/products?lang=fr_FR.
Entities will be sent to the following URL : http://my-web-server.com/entities?lang=fr_FR.
Using the following URL template : http://my-web-server.com/{destination}/{id}?lang={contextId},
The product with ID PRD0001 will be sent to the following URL : http://my-web-server.com/products/PRD0001?lang=fr_FR.
Header templating
The headers can be templated with the following values :
{uuid}: Will generate a unique ID to link all the batches of the same execution
Custom token authentication
When using CUSTOM_TOKEN authentication, you must provide two additional Javascript script parameters, loginQueryScript and tokenExtractorScript.
The first one is used to construct the body of the authentication request. It accepts the following parameters : endpoint, username, password, scope
Example :
function getLoginQueryBody(username, password)
{
return {
"username": username,
"password": password
};
}
getLoginQueryBody(username, password);
The second one is used to extract the token from the authentication request response. It accepts a single JSON parameter.
Example :
function extractToken(token)
{
return token.token_type + " " + token.access_token;
}
extractToken(token);