Bird
0
0

Given this request mapping template:

medium📝 Predict Output Q4 of 15
AWS - API Gateway
Given this request mapping template:
{
  "userId": "$input.path('$.user.id')",
  "action": "$input.path('$.action')"
}

And the incoming JSON request:
{"user": {"id": "123"}, "action": "login"}

What will be the transformed request sent to the backend?
A{"userId": "$.user.id", "action": "$.action"}
B{"userId": null, "action": "login"}
C{"userId": "123", "action": "login"}
D{"userId": "user.id", "action": "login"}
Step-by-Step Solution
Solution:
  1. Step 1: Extract values using JSONPath

    $input.path('$.user.id') extracts "123" and $input.path('$.action') extracts "login" from the request JSON.
  2. Step 2: Substitute extracted values into template

    The template replaces placeholders with extracted values, producing {"userId": "123", "action": "login"}.
  3. Final Answer:

    {"userId": "123", "action": "login"} -> Option C
  4. Quick Check:

    Mapping extracts and replaces JSON fields correctly [OK]
Quick Trick: JSONPath extracts values for mapping templates [OK]
Common Mistakes:
MISTAKES
  • Treating JSONPath as literal strings
  • Expecting null when field exists
  • Misreading JSON structure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes