Skip to content

API Gateway to EventBridge integration request param issues

0

Hello there, I am trying to pass a slightly complex object in my eventbridge integration with my HTTP API GW, but I keep getting a Bad Request error every time I pass a string. This works fine if it is a numeric value.

 x-amazon-apigateway-integration:
        integrationSubtype: "EventBridge-PutEvents"
        requestParameters:
          Detail: '{"myvar": $request.header.test}'
          DetailType: xxxx
          Source: yyy

if the header has a numeric value for test, this works fine. If I pass a string it fails. I have tried escaping the quotes in multiple ways but it does not seem to work.

3 Answers
1
Accepted Answer

Hi Try and surround the header variable with { ... } that should work I think.

 x-amazon-apigateway-integration:
        integrationSubtype: "EventBridge-PutEvents"
        requestParameters:
          Detail: '{"myvar": "${request.header.test}"}'
          DetailType: xxxx
          Source: yyy
EXPERT
answered 3 years ago
EXPERT
reviewed 3 years ago
0

On a different note, does API GW not allow you to pass thru the request body if you are passing anything else?

This works:

{"var1": "${request.header.H1}", "tid": "${request.header.H2}", "body":"${request.body.myvar}"}

But this doesn't:

{"var1": "${request.header.H1}", "tid": "${request.header.H2}", "body":"${request.body}"}
answered 3 years ago
  • Try removing the brackets for you body. Accessing the entire object should work without brackets.

  • That does not seem to work. I get an error saying: _Invalid selection expression specified: Validation Result: warnings : [], errors : [Invalid source: _

    Looks like I cannot do the whole body if I have anything else in the payload. If I target other properties on the body, it works, just not the top level body.

0

Sweet!! That did it. Is this documented anywhere?

answered 3 years ago
  • I don't think there is a clear documentation around it. I figured it out using this page

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.