title: Malformed Lambda proxy response: string indices must be integers
body: <p>I am trying to write a serverless back-end for an application with AWS Lambda, and am running into the error in the title. The error occurs when testing with API Gateway proxy integration, but the function works fine when tested in the Lambda console.</p>
  
  <p>Here is the error:</p>
  
  <pre><code>{  
     "errorMessage":"string indices must be integers",
     "errorType":"TypeError",
     "stackTrace":[  
        [  
           "/var/task/auth_login.py",
           17,
           "lambda_handler",
           "response = get_user(payload)"
        ],
        [  
           "/var/task/shifty_utils/__init__.py",
           22,
           "get_user",
           "table = dynamo.Table(user['company'] + '_users')"
        ]
     ]
  }
  </code></pre>
  
  <p>Here is context for where it occurs:</p>
  
  <pre><code>def lambda_handler(event, context):
      payload = event['body']
      response = get_user(payload)
  
  def get_user(user):
      try:
          table = dynamo.Table(user['company'] + '_users')
          response = table.get_item(
              Key={
                  'userId': user['userId'],
                  'position': user['position']
              }
          )
      except ClientError as e:
          print(e.response['Error']['Message'])
          return {'message': e.response['Error']['Message']}
      else:
          return response
  </code></pre>
  
  <p>Basically proxy integration seems to be reading in the event object as a JSON formatted string, as opposed to a dict, but here's what happens if I adjust my code for that:</p>
  
  <pre><code>{  
     "errorMessage":"the JSON object must be str, bytes or bytearray, not 'dict'",
     "errorType":"TypeError",
     "stackTrace":[  
        [  
           "/var/task/auth_login.py",
           15,
           "lambda_handler",
           "payload = json.loads(event)"
        ],
        [  
           "/var/lang/lib/python3.6/json/__init__.py",
           348,
           "loads",
           "'not {!r}'.format(s.__class__.__name__))"
        ]
     ]
  }
  </code></pre>
  
  <p>I can't win. Any help is appreciated.</p>