Senden Sie die Postanforderung an eine externe API mit AWS Lambda in PythonPython

Python-Programme
Anonymous
 Senden Sie die Postanforderung an eine externe API mit AWS Lambda in Python

Post by Anonymous »

Ich möchte jede Stunde eine Postanforderung an eine externe API (https://example.com/api/jobs/test) senden. Das habe ich wie folgt verwendet: < /p>

Handler: index.lambda_handler
python: 3.6
< /code>

Index.py

import requests
def lambda_handler(event, context):
url="https://example.com/api/jobs/test"
response = requests.post(url)
print(response.text) #TEXT/HTML
print(response.status_code, response.reason) #HTTP
< /code>

Testereignis: < /p>

{
"url": "https://example.com/api/jobs/test"
}
< /code>

Fehler: < /p>

START RequestId: 370eecb5-bfda-11e7-a2ed-373c1a03c17d Version: $LATEST
Unable to import module 'index': No module named 'requests'

END RequestId: 370eecb5-bfda-11e7-a2ed-373c1a03c17d
REPORT RequestId: 370eecb5-bfda-11e7-a2ed-373c1a03c17d Duration: 0.65 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 21 MB
< /code>

Jede Hilfe wäre geschätzt. < /p>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post