500 Internal Server Error with Mock Integration

With Mock Integration Amazon API Gateway there are 2 common reasons for 500 Internal Server error.

  1. Check the mapping template in Integration Request and ensure that you are passing statusCode as an integer to the MOCK Integration endpoint.
{
"statusCode": <Integer_Status_code>
}

Note: Make sure that status code is passed as integer not string.

Correct : 200      Incorrect : "200"

2. Mock Integrations do not support the binary content. If the API is enabled with binary support and has application/json or  */* set as binaryMediaTypes, MOCK Integration endpoints would throw a 500 Internal server error when trying to transform the content.

A workaround is to update the contentHandling property of the MOCK Integration to CONVERT_TO_TEXT

Currently, API Gateway Console unlike other Integrations does not provide a way to update the contentHandling property for MOCK Integration in Integration Request.

contentHandling property can be updated using the AWS CLI

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

AWS Documentation : https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-mock-integration.html