2
votes

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?

1
I've tried to replicated this, and I haven't been successful as of yet. Can you confirm that you have redepoyed your API after making changes to your api config? - Mark Mucha

1 Answers

1
votes

The problem ended up being with Postman, which I was using to do my queries. When I did the queries via curl in the command line, the problem went away.