I have a simple API set up in AWS API Gateway. It is set to invoke a Python 2.7 lambda function via API Gateway Proxy integration.
I hit a strange error in that the lambda worked (processed the body correctly and updated a DB) when invoked locally and through the lambda test console, but not through curl or Postman.
Turns out that, when invoked through the lambda test console, the event['body']
object is coming through as a dict
. When called via an HTTP client, it's coming through as a string (Unicode
).
I can work around it of course, but I'd like to understand it, and I'd also prefer a proper Python object. I'd also like to be able to use the lambda test console, but currently I can't as it passes its input differently.
Is there a configuration switch I'm missing which will force API Gateway to serialize the request body (as well as all other params) as a python dict
or proper object? The documentation on the specifics of what is passed is sparse, stating:
event – AWS Lambda uses this parameter to pass in event data to the handler. This parameter is usually of the Python dict type. It can also be list, str, int, float, or NoneType type.
I get that this blurb covers what I'm seeing, but it's not exactly helpful.