title: AWS Lambda python API call method not returning JSON - not serialisable?
body: <p>I have a Lambda function, which is a basic Python GET call to an API. It works fine locally, however when I upload to Lambda (along with the requests library) it will not return the JSON response from the API call. I simply want it to return the entire JSON object to the caller. Am I doing something fundamentally wrong here - I stumbled across a couple of articles saying that returning JSON from a Lambda Python function is not supported. </p>
  
  <p>Here is the code: </p>
  
  <pre><code>import requests
  import json
  url = "http://url/api/projects/"
  headers = {
     'content-type': "application/json",
     'x-octopus-apikey': "redacted",
     'cache-control': "no-cache"
      }
  
  def lambda_handler(event, context):
      response = requests.request("GET", url, headers=headers)
      return response
  </code></pre>
  
  <p>My package contains the requests library and dist, and the json library (I don't think it needs this though). Error message returned is: </p>
  
  <pre><code>    {
    "stackTrace": [
      [
        "/usr/lib64/python2.7/json/__init__.py",
        251,
        "dumps",
        "sort_keys=sort_keys, **kw).encode(obj)"
      ],
      [
        "/usr/lib64/python2.7/json/encoder.py",
        207,
        "encode",
        "chunks = self.iterencode(o, _one_shot=True)"
      ],
      [
        "/usr/lib64/python2.7/json/encoder.py",
        270,
        "iterencode",
        "return _iterencode(o, 0)"
      ],
      [
        "/var/runtime/awslambda/bootstrap.py",
        41,
        "decimal_serializer",
        "raise TypeError(repr(o) + \" is not JSON serializable\")"
      ]
    ],
    "errorType": "TypeError",
    "errorMessage": "&lt;Response [200]&gt; is not JSON serializable"
  }
  </code></pre>