IBM Support

How to specify REST Adapter Header values that contain a space character?

How To


Summary

The IBM Transformation Extender REST Adapter -HEADERS (-H) command uses a space character to delimit multiple header key and value pairs.

Additional single quotes and double quotes are required to allow the headers to parse correctly when a header value includes a space character, such as the Authorization header which uses a token as a second value.

Objective

When defining the REST Adapter -HEADERS (-H) command, the following syntax may be used to correctly parse any header value containing a space character.

Use a pair of single quotes before the first header key=value pair and after the last header key=value pair.

And enclose any header value containing a space with double quotes.

An additional set of double quotes is needed when using the REST Adapter command in a PUT() or GET() function which also uses double quotes to surround the entire adapter command.

The Hex value for a double quotes <<22>> may be used.

The SYMBOL(34) may also be used to represent the double quote character.

Examples:

-HEADERS ' key1=""value1 value2"" key2=value '

-H ' key1=""value1 value2"" key2=value '

-H ' key1=<<22>>value1 value2<<22>> key2=value '

-H ' key1="+SYMBOL(34)+"value1 value2"+SYMBOL(34)+" key2=value '

-H 'Authorization=<<22>>Bearer 1a2b3c4d5e6f7g8<<22>> Accept=application/json Content-Type=multipart/form-data'

Additional Information

The following is a typical exception seen in the REST Adapter trace file when failing to parse the Header key value pairs due to a space character in the header value.
Caught exception: com.hcl.hip.adapters.m4base.MBaseException
Invalid format for key=value pairs

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB59","label":"Sustainability Software"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSVSD8","label":"IBM Transformation Extender"},"ARM Category":[{"code":"a8m0z000000cwPoAAI","label":"Adapters->REST"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Document Information

Modified date:
11 February 2022

UID

ibm16556182