@Component("Util")
public class Util {
public void addUsernamePasswordCredentials(String username, String password, Exchange exchange) {
final String auth = Base64.encodeBase64String(String.format("%s:%s", username, password).getBytes(StandardCharsets.UTF_8));
final Map<String, Object> map = new HashMap<>();
map.put("Authorization", "Basic " + auth);
exchange.getMessage().getHeaders().put("CamelOlingo2.endpointHttpHeaders", map);
}
}
<route id="simple-route">
<from id="route-timer" uri="timer:/>
<bean ref="Util" method="addUsernamePasswordCredentials('DEMO_USER', ‘demo')"/>
<to id="_to1" uri="olingo2:/>
<log id="route-log" message=">>> ${body}"/>
</route>
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org.apache.camel.RuntimeCamelException: Error reading EDM: Unauthorized
at org.apache.camel.component.olingo2.Olingo2AppWrapper.getEdm(Olingo2AppWrapper.java:94)
at org.apache.camel.component.olingo2.Olingo2Endpoint.interceptProperties(Olingo2Endpoint.java:169)
at org.apache.camel.component.olingo2.Olingo2Producer.process(Olingo2Producer.java:58)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)