-1

I'm getting a Key error when invoking a lambda that is actually an API handler lambda. I invoke that specific route using the following sinitax:

 invoke_payload = {
        'path': '/3d/terrain/{item_id}/{proxy+}',
        'httpMethod': 'GET',
        'headers': {'Accept':'application/octet-stream'},
        'multiValueHeaders': {},
        'queryStringParameters': {'access_token':jwt_token},
        'multiValueQueryStringParameters': None,
        'pathParameters': {'dataset_id': dataset_id,'proxy':proxy_path},
        'stageVariables': None,
        'requestContext': {
            'path': '/3d/terrain/{item_id}/{proxy+}',
            'resourcePath': '/3d/terrain/{item_id}/{proxy+}',
            'httpMethod': 'GET',
        },
        'body': None,
    }
    

    #syncronous call
    response = client.invoke(FunctionName=arn,
                             InvocationType='RequestResponse',
                             Payload=json.dumps(invoke_payload))

    result = json.loads(response.get('Payload').read())
    return result

What it could be. I passed all the required pathParameters and i think the token must not be a problem.

When i make the get request in Postman i get the following:

{
"errorMessage": "'item_id'",
"errorType": "KeyError",
"stackTrace": [
    "  File \"/var/task/chalice/app.py\", line 1040, in __call__\n    for name in route_entry.view_args}\n",
    "  File \"/var/task/chalice/app.py\", line 1040, in <dictcomp>\n    for name in route_entry.view_args}\n"
]

}

New contributor
Carlos Robles is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Browse other questions tagged or ask your own question.