The idea behind REST configurations is to create a collection of HTTP requests that can be used in the pfx-rest component. This collection also predefines some common features of the target system, e.g. authentication mechanism, request headers etc.
Definition
REST configurations are represented in the XML format and are part of the configuration as a whole. This is a sample REST configuration:
<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>getRecords</name>
<uri>/api/data/{{apiVersion}}/{{recordType}}</uri>
<method>GET</method>
<properties>
<property>
<name>apiVersion</name>
</property>
<property>
<name>recordType</name>
</property>
</properties>
</rest>
</rests>
Implementation Notes
-
connectionpart defines common connection fields for all configurations.-
If
authRequestTemplateis defined, such definition will be set to the connection and have precedence over the connection setup. -
You can set up the elements
headersandconnectionshere instead of defining them for each configuration item.
-
-
restdefines a single configuration which can be referenced.-
propertiesdefine customizations to theuriparameter where the placeholder{{}}exists. -
methoddefines the HTTP request method. -
You can also set up the elements
headersandconnectionshere for fine-graining.
-
-
If the
headersorconnectionssections are defined both on therestslevel andrestlevel, the result is merge of both definitions, where therestlevel has precedence overrestsregarding duplicate items.