BackEnd: I am using using AWS Lambda Project .NET Core C#
In the backend, I am returning code something like this:
var response = new APIGatewayProxyResponse
{
StatusCode = (int)HttpStatusCode.OK,
Body = Convert.ToBase64String(fooByteArray),
IsBase64Encoded = true,
Headers = new Dictionary<string, string> { { "Content-Type", 'application/pdf' }, { "Access-Control-Allow-Origin", "*" } },
};
return response;
When I test in the Mock Lambda Test Tool, the value that it is returning is correct (I can literally copy paste the string in the front end and it will return the correct PDF values).
However, when I deploy this in AWS lambda, the response value changed (is lesser) and has some weird data in the PDF (for example, value is suppose to be $12.00, it now returns $12.000)
I tried everything, such as what I usually use:
Body = JsonConvert.SerializeObject(fooBytesWrappedInModelClass, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }),
In the end, it always returns that weird $12.000. I don't want a hack fix on the front end to handle the extra zeroes as the PDF is a huge file and there may be other texts missing.
ADDITIONAL NOTES: I tried the following
- Direct convert of byte array to Json serialize object
- Converting byte array into hex (lambda still has missing response values)
- The problem is on Lambda itself (since the value there is already different) and not in Api Gateway yet
- PDF byte array response has a range of 200K to 320K
- Amount of response missing from 320K one was 12K characters