Just doing a quick POC and see a potential issue. Please let me know if I'm doing this wrong? It's the configuration on a service callout policy.
Here's my configuration. Base64 Encoding message template is encoding the first quote and part of the string but cutting off the colon and rest of string.
<Set> <Headers> <Header name="Authorization">Basic {encodeBase64('ODde97e93b86696927d2fsd23bd14dff:t644e0a996b28fa27c228e00a008d4e3ad3d')}</Header> </Headers> </Set>
encoded string ends up being: 'ODde97e93b86696927d2fsd23bd14dff
It's weird because it includes the single quote.
Also, yes, I know this solution isn't best practice but for my quick POC it's fine.
Solved! Go to Solution.
ahh, yes those functions are a little particular about how they parse their arguments.
I think we could and should make that more robust.
But in the meantime, you can get what you want by using an interim variable.
Try this:
<AssignMessage name='AM-1'> <DisplayName>##</DisplayName> <AssignTo>request</AssignTo> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <AssignVariable> <Name>blob</Name> <Value>ODde97e93b86696927...:t644e0a9...</Value> </AssignVariable> <Set> <Headers> <Header name="Authorization">Basic {encodeBase64(blob)}</Header> </Headers> </Set> </AssignMessage>
I am not sure if an AssignVariable works in a ServiceCallout policy. You'll have to try that out.
You could also do this:
<AssignMessage name='AM-1'> <DisplayName>##</DisplayName> <AssignTo>request</AssignTo> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <AssignVariable> <Name>username</Name> <Value>ODde97e93b86696927</Value> </AssignVariable> <AssignVariable> <Name>password</Name> <Value>abcdefgdjhdkdjslk927</Value> </AssignVariable> <AssignVariable> <Name>blob</Name> <Template>{username}:{password}</Template> </AssignVariable> <Set> <Headers> <Header name="Authorization">Basic {encodeBase64(blob)}</Header> </Headers> </Set> </AssignMessage>