Reputation: 18680
I have been struggling for access a variable that was defined during the flow and now I need to use it as part of authorization header in the HTTP request component. So far I have tried the following ways:
"Bearer " ++ vars.myVar
"Bearer " ++ #[vars.myVar]
"Bearer #[vars.myVar]"
None of them works since I am able to see the raw input in the console logs which reads as follow:
POST /webserviceurl HTTP/1.1
accept: application/json
authorization: "Bearer " ++ #[vars.myVar]
x-correlation-id: 06386edf-93a9-4d38-a117-d971f9eb7c11
Host: test.salesforce.com:443
User-Agent: AHC/1.0
Connection: keep-alive
Content-Type: application/json
Here is the definition for the HTTP request config:
<http:request-config name="HTTP_Request_configuration" doc:name="HTTP Request configuration" doc:id="ad136a30-3119-44d1-ac13-8163214df28b" >
<http:request-connection protocol="HTTPS" host="${SalesforceBaseUrl}" port="443" >
</http:request-connection>
<http:default-headers >
<http:default-header key="content-type" value="application/json" />
<http:default-header key="accept" value="application/json" />
<http:default-header key="Authorization" value='"Bearer " ++ #[vars.myVar]' />
</http:default-headers>
</http:request-config>
What I am missing here? Which one is the right way to access a variable there?
Upvotes: 0
Views: 304
Reputation: 1538
Your value can't be mixed, it's either an expression or a literal string (except in the logger).
So in this case it should be:
#["Bearer " ++ vars.myVar]
Upvotes: 3