-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Recieved from Andrea Catalucci:
I’m using your serverless-python-sample git repo as a starting point for a python project, and after successfully deploying the service I am not able to call the functions through curl.
I’ve followed README.md instructions with no problems, I can invoke both functions successfully (locally and remotely with -p event.json), but calling them through the web API doesn’t seem to work.
I constantly get: {"message": "Internal server error”}
In the CloudWatch logs i see:string indices must be integers: TypeError
Traceback (most recent call last):
File "/var/task/handler.py", line 24, in get_post
url = API_HOST + '/posts/' + event['path']['id']
TypeError: string indices must be integersI investigated the issue, and i noticed that when calling the API with curl, the event object changes.
I analysed the json returned by jsonplaceholder.typicode.com, and I can confirm there is no event[‘path’][‘id’]; instead one should use event[‘pathParameters’][‘id’]
But even after changing that, I couldn’t make the curl command return the intended jsonThanks for your attention,
Andrea Catalucci