简体   繁体   中英

How to set the Headers.$ input for Step functions to invoke api gateway?

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!

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.

  1. Set request parameter mapping to map method.request.header.x-Authorization to Authorization header. documentation
  2. Set accepting custom request header x-Authorization . documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM