Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

TypeError: string indices must be integers #2

Copy link
Copy link
@bennybauer

Description

@bennybauer
Issue body actions

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 integers

I 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 json

Thanks for your attention,
Andrea Catalucci

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.