Bird
0
0

Consider this response mapping template:

medium📝 Predict Output Q5 of 15
AWS - API Gateway
Consider this response mapping template:
{
  "status": "$input.path('$.statusCode')",
  "message": "$input.path('$.body.message')"
}

Given the backend response:
{"statusCode": 200, "body": {"message": "Success"}}

What will the client receive?
A{"status": 200, "message": "Success"}
B{"status": "$.statusCode", "message": "$.body.message"}
C{"status": "200", "message": "Success"}
D{"status": null, "message": "Success"}
Step-by-Step Solution
Solution:
  1. Step 1: Extract fields using JSONPath

    $input.path('$.statusCode') extracts 200, converted to string "200"; $input.path('$.body.message') extracts "Success".
  2. Step 2: Form response JSON

    Values are inserted as strings, resulting in {"status": "200", "message": "Success"}.
  3. Final Answer:

    {"status": "200", "message": "Success"} -> Option C
  4. Quick Check:

    Response mapping converts backend data to strings [OK]
Quick Trick: Mapping templates convert all values to strings by default [OK]
Common Mistakes:
  • Expecting numbers instead of strings
  • Using literal JSONPath strings
  • Missing nested field extraction

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes