我想覆盖从此集成发送的响应正文。我指的是这个链接https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-parameter-mapping.html
它说使用overwrite:$response.body
。但这不起作用。我给出错误说“无效的目标参数”
APIVersionIntegration:
Type: AWS::ApiGatewayV2::Integration
Properties:
ApiId: !Ref HttpApi
ConnectionType: INTERNET
CredentialsArn: !GetAtt MyHttpApiRole.Arn
IntegrationType: AWS_PROXY
RequestParameters:
MessageBody: "$request.body"
QueueUrl: !Ref DataPublisherSQS
ResponseParameters:
"200":
ResponseParameters:
- Source: "application/json"
Destination: "overwrite:header.content-type"
- Source: ""
Destination: "overwrite:$response.body"
IntegrationSubtype: "SQS-SendMessage"
# IntegrationMethod: POST
PayloadFormatVersion: "1.0"
最佳答案
我有完全相同的问题(与 SQS 集成,我想返回一个空的 JSON)。
阅读文档,似乎无法覆盖响应正文,只能修改 header 和状态代码:https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-parameter-mapping.html#http-api-mapping-response-parameters
也许唯一的方法是在 Lambda 中包装 SQS 消息发送
关于amazon-web-services - HttpApi 与 AWS::ApiGatewayV2::integration 如何覆盖响应正文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73463191/