내용으로 건너뛰기

in AWS API Gateway how can I pass data from Integration Request to Integration Response when I'm using mock integration

0

Hello. I don't want to use Lambda function. I want to directly pass data from Integration Request to Integration Response. my Integration Request's mapping template looks like this :

{
  "statusCode": 200
}

I want to extract statusCode from this and use it in Integration Response. I'm trying it in following way :

{
"provided_statusCode": "$input.path('$.statusCode')"
}

I also tried input.json('$.statusCode') but it doesn't work. can anyone help? I got response :

{
  "provided_statusCode": ""
}
1개 답변
2
수락된 답변

In API Gateway you have to create Integration Response and Method Response for each status code (200, 302, 400, 500) you want to present.

You can get all data from Integration Request into Integration Response except Status Code since API Gatewway manages it for you.

Here's an example of getting the body from Integration Request into Integration Response when using Mock:

Integration Request
#set($context.requestOverride.path.body = $input.body)
{
  "statusCode": 200,
}
Integration Response
#set($body = $context.requestOverride.path.body)
{
  "statusCode": 200,
  "body": $body,
}
AWS
답변함 3년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠