Python at AWS Lambda: `requests` from botocore.vendored deprecated, but `requests` not available

后端 未结 7 2186
梦如初夏
梦如初夏 2021-02-07 16:07

I\'ve got a Python script for an AWS Lambda function that does HTTP POST requests to another endpoint. Since Python\'s urllib2.request, https://docs.python.org/2/li

7条回答
  •  醉酒成梦
    2021-02-07 16:51

    I succeeded sending HTTP POST requests using the urllib3 library, which is available at AWS Lambda without the requirements for additional installation instructions.

    import urllib3
    
    http = urllib3.PoolManager()
    
    response = http.request('POST',
                            url,
                            body = json.dumps(some_data_structure),
                            headers = {'Content-Type': 'application/json'},
                            retries = False)
    

提交回复
热议问题