I have a Lambda, written in Java, from which I want to output binary data (namely Excel spreadsheets). I noticed that the data being returned by the Lambda is mutated by Api Gateway. To investigate the problem, I created a simple Lambda which outputs:
{
"statusCode": 200,
"headers": {},
"body": "AOld",
"isBase64Encoded": true
}
This corresponds to the three (hex) bytes:
00 E9 5D
I then set up an API in Api Gateway. The API consists of a simple method on the root resource, whose integration request is a Lambda Function, with proxy integration, pointing at the above Lambda. I am passing in Content-Type and Accept headers, and the content types being used are marked as Binary media types. When this passes through API Gateway, however, I get
00 EF BF BD 5D
Any idea why Api Gateway is mangling my binary output?