0
0
AWScloud~10 mins

Request and response mapping in AWS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the integration request mapping template in AWS API Gateway.

AWS
"requestTemplates": {"application/json": [1]
Drag options to blanks, or click blank then click option'
A"{ \"statusCode\": 200 }"
B"{ \"error\": \"Not found\" }"
C"{ \"message\": \"Hello\" }"
D"{ \"body\": $input.body }"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a static JSON string instead of passing the request body.
Incorrectly escaping quotes in the JSON string.
2fill in blank
medium

Complete the code to specify the integration response mapping template to extract a message from the backend response.

AWS
"responseTemplates": {"application/json": [1]
Drag options to blanks, or click blank then click option'
A"{ \"result\": $input.path('$.message') }"
B"{ \"error\": $input.path('$.error') }"
C"{ \"status\": 200 }"
D"{ \"body\": $input.body }"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong JSON path expression.
Not wrapping the output in a JSON string.
3fill in blank
hard

Fix the error in the integration request mapping template to correctly pass a query parameter named 'id'.

AWS
"requestTemplates": {"application/json": "{ \"id\": \"[1]\" }"}
Drag options to blanks, or click blank then click option'
A$input.params().querystring.id
B$input.params('querystring').id
C$input.params('id')
D$input.params('query').id
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method calls or syntax to access query parameters.
Confusing path parameters with query parameters.
4fill in blank
hard

Fill both blanks to create a response mapping template that returns the status code and a message from the backend response.

AWS
"responseTemplates": {"application/json": "{ \"statusCode\": [1], \"message\": \"[2]\" }"}
Drag options to blanks, or click blank then click option'
A$input.path('$.statusCode')
B$input.path('$.message')
C200
D$input.path('$.status')
Attempts:
3 left
💡 Hint
Common Mistakes
Using hardcoded values instead of extracting from response.
Incorrect JSON syntax or missing quotes.
5fill in blank
hard

Fill all three blanks to create a request mapping template that passes a path parameter 'userId', a query parameter 'filter', and the request body to the backend.

AWS
"requestTemplates": {"application/json": "{ \"userId\": \"[1]\", \"filter\": \"[2]\", \"body\": [3] }"}
Drag options to blanks, or click blank then click option'
A$input.params('userId')
B$input.params().querystring.filter
C$input.body
D$input.path('$.body')
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up path and query parameter syntax.
Not properly escaping JSON strings.
Using incorrect methods to access the request body.