Reputation: 21507
The following template returns ''
if the Authorization header is not present. How can i get null
instead? So return null
if key is not present...
{
"headers" : {
"authorization" : "$input.params().header.get('Authorization')"
}
}
Upvotes: 2
Views: 2742
Reputation: 6535
You can use #if ($variable)
to check if a variable is not null
#if ($variable)
... do stuff here if the variable is not null
#end
In your use case, you can try to put the null check around the authorization header, like this.
{
"headers" : {
#if( $input.params().header.get('Authorization').toString() != "" )
"authorization" : "$input.params().header.get('Authorization')"
#end
}
}
Upvotes: 4