Reputation: 1928
I'm not able to create new header in Request Integration using context data.
I've used an lambda authorizer to return context and mapped them in Template Mapping.
Response from lambda authorizer:
{
<<allow policy here>>,
"context": {
"uid": "some user id"
}
}
Attempt 1:
But, I was not able to use data from context to generate header for integration.
HTTP Headers
------------------------------------------
| Name | Mapped from |
------------------------------------------
| myheader | context.authorizer.uid |
------------------------------------------
The uid does not get mapped to myheader field, nor the header shows up.
Attempt 2:
I've also tried using in VTL to remap $input.params().header.myheader = "$context.authorizer.uid"
using Template Mapping and tried to map that header
HTTP Headers
---------------------------------------------
| Name | Mapped From |
---------------------------------------------
| myheader |method.request.header.myheader|
---------------------------------------------
This also didn't worked for me. What is the possible solution to send "some user id"
in integration request header?
Upvotes: 0
Views: 1192
Reputation: 1145
You may have to put $context.authorizer.uid
in Attempt 1.
PS: The above reference says
Mapping template overrides cannot be used with proxy integration endpoints, which lack data mappings.
So do verify if your integration is "proxy integration"
Edited:
In the mapping template you have set a request header override by adding the following: #set($context.requestOverride.header.myheader = $context.authorizer.uid)
Upvotes: 1