Bird
0
0

A response mapping template uses this code:

medium📝 Debug Q7 of 15
AWS - API Gateway
A response mapping template uses this code:
{
  "result": "$input.path('$.data.result')",
  "error": "$input.path('$.errorMessage')"
}

The backend sometimes returns no errorMessage field. What issue might occur?
AThe client will receive an error HTTP status
BThe mapping template will cause a syntax error
CThe entire response will fail to map
DThe error field will be null or empty in the response
Step-by-Step Solution
Solution:
  1. Step 1: Understand missing fields in mapping

    If errorMessage is missing, $input.path returns null or empty string for "error".
  2. Step 2: Effect on response

    The response still succeeds but the "error" field is null or empty, not causing failure.
  3. Final Answer:

    The error field will be null or empty in the response -> Option D
  4. Quick Check:

    Missing fields map to null, no syntax error [OK]
Quick Trick: Missing JSON fields map to null, not errors [OK]
Common Mistakes:
  • Expecting syntax errors on missing fields
  • Assuming entire response fails
  • Confusing mapping with HTTP status

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes