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.

Here is the 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

My package contains the requests library and dist, and the json library (I don't think it needs this though). Error message returned is: