A developer is configuring an Amazon API Gateway REST API that integrates with an HTTP backend service hosted on-premises. The backend service requires a custom HTTP header named X-Backend-Token, which must be populated using the client's identity identifier found in the $context.authorizer.claims.sub context variable. Additionally, the backend service returns responses in XML format, but the API client expects a JSON payload.
Which two configurations must the developer implement in API Gateway to achieve this integration? (Select TWO.)
- Set the integration type of the API method to HTTP Integration.Answer
- In the Integration Request settings, map the X-Backend-Token header to context.authorizer.claims.sub.Answer
- CSet the integration type of the API method to HTTP Proxy Integration.
- DIn the Method Request settings, map the X-Backend-Token header to context.authorizer.claims.sub.
- EIn the Integration Response settings, define a mapping template for the application/xml content type to transform the XML payload to JSON.
Answer
Configure the integration type as HTTP Integration (non-proxy) and map the X-Backend-Token header to context.authorizer.claims.sub under the Integration Request settings.
The correct options are configuring the integration type to HTTP Integration and mapping the custom header under the Integration Request settings. HTTP Integration (custom integration) must be used instead of HTTP Proxy Integration because proxy integrations pass the client request and backend response directly through without modification, preventing any header injection or payload transformation. Mapping context variables to backend headers is configured in the Integration Request settings, which define the backend request structure.
Step-by-Step Solution
Key Concept
Custom HTTP integration allows request header injection from context variables and response mapping templates for data transformation, which is not possible with proxy integrations.