I'm writing an AWS reliant application in javascript and I'm utilizing the AWS CLI to automate the build process for my AWS resources. I'm attempting to create an API Gateway resource with CORS enabled. While calling the put-integration-response
method of the api gateway CLI, when I add the --response-parameters
argument, I received the following error:
>> Error parsing parameter '--response-parameters': Invalid JSON: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
>> JSON received: {method.response.header.Access-Control-Allow-Origin:'*'}
Here is the --response-parameters argument that is causing issues:
--response-parameters {"method.response.header.Access-Control-Allow-Origin":"\'*\'"}
If it helps, this argument is being fed via the grunt-exec plugin for Grunt. What exactly is causing this issue? I've tried adding more double quotes, but they don't seem to appear in 'JSON received'.
Here is another fix for this problem from here
Basically you use \ before quotes inside of JSON on Windows: Linux/Mac:
--expression-attribute-values '{ ":u": {"S":"anotherUser"}}'
will be like this on Windows:
--expression-attribute-values '{ \":u\": {\"S\":\"anotherUser\"}}'
Hope it helps to fix your error
I had the same problem while following an AWS Lambda Functions tutorial where I couldn't get the response-models argument to accept JSON (on Windows 10) no matter what I tried. I finally figured it out: I created a file named response-models.json with the contents on the first line of the file as {"application/json": "Empty"} and I saved it in the current directory. Then as the value of the response-models argument I used file://response-models.json IMPORTANT: the file must be saved in a format WITHOUT the BOM so that only the ASCII characters will come out of it and no other gibberish. (I used Sublime Text which allows one to save in UTF-8 with no BOM, as well as many other formats.) Et Voila! I got back the following response:
{
"statusCode": "200",
"responseModels": {
"application/json": "Empty"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With