rest-compatible methods

Following methods can be used:

  • get

  • post

  • put

  • delete

  • head

  • options

  • trace

  • patch

All methods are transcript for an actual call. For example, pfx-rest:get will eventually call GET https://test.me/...

Properties

Option

Type

Since Version

Default

Description

Option

Type

Since Version

Default

Description

uri

string

 

 

URI to fetch data from.

If the parameter url is specified on the connection, only the resource path must be provided (e.g. /v2/accounts).

If the parameter url is not specified on the connection, the full path must be provided (https://...).

If there are parameters needed in URI, each parameter should be placed as a placeholder %s.


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. File location can be set using the downloadDir option.

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. 

inputSource

string

4.7.0

 

Defines input source for data in exchange. It can be stored in the header, property or body.

inputSourceName

string

4.7.0

 

Defines input source name for the source type header and property. Put here the name of the exchange header or exchange property.

outputTarget

string

4.7.0

 

Defines output target for data in exchange. It can be stored in the header, property or body.

outputTargetName

string

4.7.0

 

Defines output target name for the target type header and property. Put here the name of the exchange header or exchange property.

downloadDir

string

4.9.0

 

If disableStreamCache is set to true, this option can be used to set a custom temporary file directory location (for example to make sure the location is accessible from the route).

Unknown Properties

Unknown properties are handled as query parameters. For details see the section below.

An exception is when using the method pfx-rest:system – in this case, unknown properties are handled as properties.

Input Source / Output Target

A standard way to put data to a component or retrieve them from a component is using body. However, in certain cases it is not the best option. Hence the inputSource, inputSourceName, outputTarget and outputTargetName properties were created to tackle the problem.

An example how to define a component that fetches data from the header header1:

<to uri="pfx-rest:post?uri=http://localhost:8080/api/ad/data&amp;inputSource=header&amp;inputSourcenName=header1"/>

Example how to populate data from the body:

<setBody> <constant>body123</constant> </setBody> <to uri="pfx-rest:post?uri=http://localhost:8080/api/ad/data"/>

Body is default option. You can also set inputSource=body, the effect would be the same.

Example how to send results to the property prop1:

<to uri="pfx-rest:post?uri=http://localhost:8080/api/ad/data&amp;outputTarget=property&amp;outputTargetName=prop1"/>

The toD Problem

The toD option might seem more dynamic:

However, this option has a caveat described here. In short, using toD interpolates the parameters, so the result component is:

When you change the data in the header MyCustomMap to data2, this component would be created:

So if the parameter has variable content (let’s say n), there would be n components and endpoints created, which would negatively affect performance.

In this case, if you use static parameters with <to....inputSource=header&inputSourceName=head1, only one component and one endpoint would be created for all possible values, offering top performance.

Handling ZIP Response

If an endpoint returns a ZIP response (content-type=application/zip) and the disableStreamCache option is set to false, then the response will be stored into memory as a Base64 encoded string. This allows you to work with the ZIP file in a route.

Examples

Call with payload from header

Request body: {"somedata":"exactly as endpoint expects"}

 

Call with result stored in header

Result data will be stored in the header myHeader.

 

Call with result stored to property

Result data will be stored to the property named myProp.

IntegrationManager version 5.8.0