pfx-rest:system

This method is different from all other methods – it uses System Configurations to easier communicate with known 3rd party systems. It allows you to have templates for your preferred system and thus you do not need to handle the actual calls.

Properties

Option

Type

Default

Description

Option

Type

Default

Description

connectionTimeoutMs

integer

20000

Connection timeout in milliseconds. Used both for authentication and fetch.

maxResponseSizeInMB

integer

0

Defines maximum size of a response in MB. After reaching the limit, an exception will be thrown. If the default value (0) is set, the response size is not checked.

contentType

string

application/json

Content type of the fetch request. The value has to follow the HTTP standard.

okStatusCodeRange

string

200-299

Status codes which are considered a success response. The values are inclusive. Multiple ranges can be defined, separated by a comma, e.g. 200-204,209,301-304. Each range must be a single number or from-to with the dash included.

proxyHost

string

 

Proxy address to use.

proxyPort

integer

 

Proxy port to use.

connection

string

 

Name of an existing connection which will be used to access the resource.

autoDecode

Boolean

true

Indicates that encoded data (gzip, deflate, ...) should be automatically decoded.

failIfNoConnection

Boolean

false

Determines whether to fail if a connection is missing or whether to use the default connection.

disableStreamCache

Boolean

false

If set to true, the content is streamed directly to a file. Otherwise the content is stored to the memory.

fileKey

string

file

If a multipart file is uploaded, specifies a key of the file.

useBoundary

Boolean

true

If a multipart file is uploaded, determines whether to use boundary in the request body and content type. 

systemName

string

 

System name. Used for referencing System Configurations. It is mandatory for this method.

systemConfigurationItem

string

 

System configuration item. Used together with systemName to determine which configuration item should be used. It is mandatory for this method.

Examples

For example, let's assume we have a configuration for MS Dynamics system. The configuration looks like this:

<system>     <systemName>MSDynamics</systemName>     <rests>         <connection>             <connections>                 <connection>net.pricefx.integration.component.rest.domain.connection.OAuth2Connection</connection>             </connections>             <authRequestTemplate>{"grant_type": "client_credentials", "client_id": "::clientId", "client_secret": "::clientSecret", "scope": "::scope"}</authRequestTemplate>             <headers>                 <header>                     <name>OData-MaxVersion</name>                     <value>4.0</value>                 </header>                 <header>                     <name>OData-Version</name>                     <value>4.0</value>                 </header>                 <header>                     <name>Prefer</name>                     <value>return=representation</value>                 </header>             </headers>         </connection>         <rest>             <name>versions</name>             <uri>/api/data/{{apiVersion}}</uri>             <method>GET</method>             <properties>                 <property>                     <name>apiVersion</name>                 </property>             </properties>         </rest>     </rests> </system>

 

We use the configuration in the following route:

<route>     <from uri="direct:start"/>     <to uri="pfx-rest:system?connection=qa_salesforce_michalstepan_oauth&systemName=MSDynamics&systemConfigurationItem=versions&amp;apiVersion=v9.1"/>     <log message="Loading done!"/>     <to uri="mock:end"/> </route>

Note that we set the apiVersion parameter which is a property for the versions configuration above.

As you can see, configuration permits a connection of the type OAuth2Connection and also sets some default headers, authentication template, URI and request method.

This leads to the following authentication communication (if there is valid OAuth2 connection).

------AUTHENTICATION REQUEST----- >> POST https://login.microsoftonline.com/789...d4c/oauth2/v2.0/token >> Headers: java.net.http.HttpHeaders@89a060f3 { {Content-Type=[application/x-www-form-urlencoded]} } >> Timeout: Optional[PT20S] >> Autodecode: true >> Body: grant_type=client_credentials&client_id=80c49...cb05e161f5&client_secret=ZroVn...D6Z_&scope=https://pricefx.crm.dynamics.com/.default ---------------------------------

Notice the scope parameter in the request body (taken from the configuration above – authRequestTemplate).

 

The actual request interaction:

 

Notice the headers in the request – taken from the system configuration.

IntegrationManager version 5.8.0