restRequest
Processor that produces a message from a REST endpoint.
Properties
Name | Summary |
---|---|
|
URL of the REST service to call. Required. |
|
The |
|
Optional |
|
Optional. When set to true, the entity will be converted to a string, regardless of |
|
Optional default value for the |
|
Secrets key used to look up credentials to append to the request (e.g., as an authorization header). Also supports a comma separated list of Secrets keys, if multiple authentication methods are required on the same request. Optional. |
|
Optional, comma separated list of response headers to forward. Wildcard When forwarding headers, the casing of the selection configurations is used, not the casing of the actual header names. The |
|
Optional, comma separated list of response status codes or response status code ranges that will not result in message failure. When a non-success status is returned, and the status is found in the list of non-failure statuses, the response entity is set as the payload. Can be configured with error status codes from client (4xx), server (5xx) error status families, and 304 (Not Modified). |
|
Whether the response status code is to be stored as an exchange property under the key |
|
Connection timeout value. Optional. |
|
Socket timeout value. Optional. |
|
Hostname of the proxy server to use. Optional. |
|
Port of the proxy server to use. Optional. |
|
Key from the server configuration used to look up proxy credentials to append to the request. Optional. |
|
Optional key from the server configuration used to look up SSL credentials for server and client authentication. |
|
Optional |
|
Optional |
|
Optional, descriptive name for the processor. |
|
Required identifier of the processor, unique across all processors within the flow. Must be between 3 and 30 characters long; contain only lower and uppercase alphabetical characters (a-z and A-Z), numbers, dashes ("-"), and underscores ("_"); and start with an alphabetical character. In other words, it adheres to the regex pattern |
|
Optional set of custom properties in a simple jdk-format, that are added to the message exchange properties before processing the incoming payload. Any existing properties with the same name will be replaced by properties defined here. |
|
Whether the incoming payload is available for error processing on failure. Defaults to |
Sub-builders
Name | Summary |
---|---|
Strategy for providing message processing hints to the server. Optional. |
|
Strategy for describing the external system integration. Optional. |
|
Strategy for configuring the processor’s circuit breaker. Optional. |
|
Strategy for describing how a processor’s message is logged on the server. |
|
Strategy for archiving payloads. |
|
Strategy that customizes the conversion of an incoming payload by a processor (e.g., string to object). Should be used when the processor’s default conversion logic cannot be used. |
Details
Responses
The restRequest
processor does not perform unmarshalling of responses but returns them as JSON strings that can be unmarshalled with an inboundTransformationStrategy
later in the flow if needed.
When conversion requires a characterSet
config, these character encoding constants are supported.
If the payload is to be converted from an object, the conversion format can be specified as JSON, JAXB, or XML.
Encoding for parsing the response is chosen by the following priority:
-
The
charset
from theContent-Type
header -
The
charset
from thedefaultAcceptedContentType
config parameter -
The
charset
from thedefaultEntityContentType
config parameter -
Default:
UTF-8
for MIME type JSON, andISO_8859_1
otherwise
If a failure occurs during processing, a response code within the 400 range will be interpreted as a non-transient failure (i.e., a retry should be attempted). All other failures are considered transient.
Supported Methods
The restRequest
processor supports the following HTTP methods:
Method | Description |
---|---|
POST |
If Otherwise, the payload will be used as the request entity. The payload will be converted to a string or treated as binary data, depending on the See the MDN web docs for specifics on form parameter encoding. |
GET |
The properties of the payload will be used as query string parameters, based on the |
POST
, PUT
and PATCH
requests will use the defaultEntityContentType
value as the Content-Type
header.
If not provided, then application/json; charset=UTF-8
will be used.
If only the media type is provided (e.g., application/json
), the charset
will default to UTF-8
.
Payload Properties as Query Parameters
The PayloadPropertiesAsQueryParameterStrategy enum controls how payload properties are handled as query parameters for GET and DELETE requests:
-
GET_AND_DELETE
: Properties are used as query parameters for both GET and DELETE requests. -
GET
: Properties are used as query parameters only for GET requests. -
DELETE
: Properties are used as query parameters only for DELETE requests. -
NONE
: Payload properties are not included as query parameters for any requests.
Exchange Properties
Before Processing
Various message exchange properties can be set before the restRequest
processor is executed to alter the request that is made.
For example, the address could have parameters (enclosed in curly braces) that would be replaced by the corresponding message exchange properties prefixed with requestParameter
.
The following setup demonstrates how this might work:
exchangeProperties="requestParameter.param1=api"
address = URL("https://example.org/path/{param1}/")
Message properties prefixed with requestHeader
will be converted into HTTP request headers.
For example, a property named requestHeader.foobar
with a value of baz
would result in a request header of
foobar: baz
.
It’s also possible to override the address, request method, authentication config, and/or ssl authentication config by setting the exchange properties addressOverride
, httpMethodOverride
, authConfKeyOverride
, and sslAuthConfKeyOverride
respectively. You can use constants ADDRESS_OVERRIDE
, HTTP_METHOD_OVERRIDE
, AUTH_CONF_KEY_OVERRIDE
, and SSL_AUTH_CONF_KEY_OVERRIDE
to more easily access these names.
For example:
setExchangeProperty {
id = "set-address-property"
propertyName = ADDRESS_OVERRIDE
source = "envelope.payload.header.replyAddress"
}
After Processing
All consumed message properties (addressOverride
, httpMethodOverride
, authConfKeyOverride
, sslAuthConfKeyOverride
, requestHeader.*
, requestParameter.*
) will be removed after processing and not forwarded to the next processor. The restRequest
processor will also filter out any existing responseHeader.*
message exchange properties, regardless if the responseHeadersToForward
property was configured.
Note that responseHeadersToForward
uses a case-insensitive search to find matching headers but will set the exchange property to the case of the configuration and not the actual header.
For instance, responseHeadersToForward="foo"
might find a header called FOO
, but the exchange property becomes responseHeader.foo
.
However, if the wildcard (*
) is used, then the original header is returned as responseHeader.FOO
.
The restApi source processor uses the same responseHeader.* exchange properties to affect the final response that is returned for that flow.
Keep in mind that restRequest could not only remove headers you intended for the restApi flow’s response but could also set headers you didn’t intend for the flow’s response.
If the latter is the case, you would need to delete those exchange properties before the response is returned.
|
If the retainStatusCode
property is set to true
, a responseStatusCode
message exchange property is created.
Unlike the responseHeader.*
exchange properties, there is no overlap with the restApi
processor.
A flow with a restApi
source uses a separate httpResponseCode
exchange property to override the status code for its response.
Thus, if you want the restApi
flow to return the same status code as restRequest
, you must copy over the value from responseStatusCode
to httpResponseCode
.
For example:
setExchangeProperty {
id = "set-status"
propertyName = "httpResponseCode"
source = "exchangePropertiesMap['responseStatusCode']"
}
Authentication
The authenticationConfigKey
property supports secrets of the following types:
See the Secret Types documentation for formatting details of each type.
TLS (SSL) Configuration
Requests can be sent to third-party web services using HTTPS protocol. :imageprefix:
If the target service is using a valid SSL certificate, signed by a trusted CA, there is no need for additional configuration. However, configuration must be provided if you require one of the following features:
-
Providing a client certificate (if requested by the server).
-
Providing a truststore for server certificate validation. This is useful, for example, when the root certificate has not been signed by a trusted CA.
-
Limiting the server certificate to a specified public key.
-
Accepting a self-signed server certificate.
-
Accepting a server certificate issued for a host other than the one being requested.
To enable these features, the sslAuthenticationConfigKey
property must be set and point to a secret of type Tls.
See the Secret Types documentation for formatting details.