Disable Content-Type conversion in Mock integration

Using AWS CLI to disable Content-Type conversion in MOCK integration when Binary media types are enabled on API Gateway.

When Binary Media Types are enabled on a REST API with '/' or 'application/json', API Gateway converts payloads based on Content-Type headers, but MOCK integrations don't support binary content. This often results in 500 error.
To resolve this, the Content Handling behavior must be set to 'CONVERT_TO_TEXT' for the Integration request, which can only be done via AWS CLI and not via the console at the moment.

The contentHandling property of the MOCK Integration can be set to CONVERT_TO_TEXT using the following CLI command (NOTE: replace the API ID, resource ID and AWS region):

aws apigateway update-integration --rest-api-id <your-rest-api-id> --resource-id <resource-id> --http-method OPTIONS --patch-operations "op='replace' ,path='/contentHandling' ,value='CONVERT_TO_TEXT'" --region <region-of-api>
                                


Created by:

Pallavi Bhat

Pallavi Bhat

Pallavi is a Cloud Support Enginner focusing on serverless at Amazon Web Services.

Follow on LinkedIn