Overview
Defines a connection to an external REST API using HTTP Basic Authentication.
Connection File: connections/erp-system.json
JSON
{
"name": "erpSystem",
"type": "rest-basic",
"url": "https://{{erp.host}}/api",
"username": "{{erp.username}}",
"password": "{{erp.password}}"
}
Properties:
erp.host=erp.example.com
erp.username=integration-user
erp.password=secret
Using the Connection in Routes
XML
<routes xmlns="http://camel.apache.org/schema/spring">
<route id="fetchFromErp">
<from uri="timer://trigger?repeatCount=1"/>
<to uri="pfx-rest:get?uri=/products&connection=erpSystem"/>
<to uri="pfx-csv:unmarshal?header=sku,label,price"/>
<to uri="pfx-api:loaddata?objectType=P&mapper=productMapper"/>
</route>
</routes>
Common Pitfalls
-
Use
rest-basicfor username/password auth; userest-oauth2for token-based auth -
The
urlis the base URL — theuri=parameter in routes is appended to it -
For public APIs with no auth, use
rest-publictype (omit username/password)