How to add headers in existing AWS API gateway integration request

1.3k Views Asked by At

I have created a Integration Request, I am trying to add headers to that request using AWS cloudshell:

aws apigateway update-integration --rest-api-id abcdefgh --resource-id abcdefghj --http-method POST --request-parameters {"integration.request.header.X-mobile":"context.authorizer.mobile"}

But it is not working, I have tried PUT integration as well, It was giving the below error:

An error occurred (BadRequestException) when calling the PutIntegration operation: Enumeration value for HttpMethod must be non-empty

2

There are 2 best solutions below

0
On

Adding --integration-http-method POST solved it for me when doing this with AWS CLI.

As per the documentation:

For Lambda integrations, you must use the HTTP method of POST for the integration request, according to the specification of the Lambda service action for function invocations.

0
On

Try add those command options:

  • --integration-type eg. AWS_PROXY
  • --integration-method eg. POST
  • --integration-uri eg. arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${LambdaForSimpleProxy.Arn}/invocations

Here you will find values exmple: Lambda Proxy

I had similar issue in cloudformation, when you are using integration some options are conditional AWS::ApiGateway::Method Integration

Unfortunately aws cli docs doesn't mention this.