While running the below command of the recipe 'Building your first API with Lambda integration' of Chapter 2, I am getting an exception.
aws apigateway put-integration \
--rest-api-id 19sh9qhri2 \
--resource-id n9iev1 \
--http-method GET \
--type AWS \
--integration-http-method POST \
--uri 'arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:<account_id>:function:lambda-for-api-gateway/invocations' \
--request-templates '{"application/json": "{\"name\": \"$input.params('"'"'name'"'"')\" , \"time\": \"$input.params('"'"'time'"'"')\"}"}' \
--region us-east-1 \
--profile admin
Exception is
Unknown options: ,, "time":, "$input.params('''time''')"}}' ^, "$input.params('''name''')"
Please add correct escape characters specific to windows so that the final velocity mapping template for api gateway is below
I tried below value for request template
--request-templates {\"application/json\":{\"name\":\"$input.params(name)\",\"time\":\"$input.params(time)\"}}
But got the exception
Invalid type for parameter requestTemplates.application/json, value: OrderedDict([('name', '$input.params(name)'), ('time', '$input.params(time)')]), type: <class 'collections.OrderedDict'>, valid types: <class 'str'>
Tried mulitple options. Either getting above error or the first Unknown exception error.
Please use the below line for request template
Multiple escape characters are required because params should be in single quote for velocity template and while running the commands you will see below console output
This will create correct velocity template for api-gateway
It worked, Thanks a ton!
1.AWS
2.Cloud
3.Database
4.Certification
5.DevOps