Reputation: 51
When I used the step function to invoke API Gateway, I filled the "Headers.$": "$.input.headers", but when I test it, it gives me could not be used to start the Task: [The value of the field 'Headers' has an invalid format]
every time,
I tried this
"input": {
"headers": {
"Authorization": "abcd",
"Content-Type": "application-json"
}
}
it doesn't work, could anyone give me an example of this headers field?
Really appreciate!
Upvotes: 3
Views: 3003
Reputation: 61
I met same problem. And I resolved it as following.
First, we cannot use Authorization
header and other some headers as the note of this documentation. So we should use a custom header. It is mapped to Authorization
header in API Gateway.
Next, from what I've tried, we probably should use array format in value of Headers
.
So you can write as following:
"input": {
"headers": {
"x-Authorization": ["abcd"],
"Content-Type": ["application-json"]
}
}
and I use intrinsic functions as following:
"Headers":{
"x-Authorization.$":"States.Array(States.Format('Bearer {}', $.SecretOutput.Token))"
}
And finally, we should set two configration in API Gateway.
method.request.header.x-Authorization
to Authorization
header. documentationx-Authorization
. documentationUpvotes: 6