Reputation: 103
I am trying to simply insert one item using json as input file. I am running command on Windows Cmd prompt:
aws2 dynamodb put-item --table-name testCLI --item file://C:\Temp\DynamoDB\item.json
table testCLI has 2 attributes - ID and Value
File item.json:
"{\"ID\": {\"N\":\"2\"}, \"Value\": {\"S\": \"From json file with escape characters\"}}"
I am getting error:
Error parsing parameter '--item': Expected: '=', received: '"' for input: "{\"ID\": {\"N\":\"2\"}, \"Value\": {\"S\": \"From json file with escape characters\"}}"
aws2 --version
aws-cli/2.0.0dev3 Python/3.7.5 Windows/10 botocore/2.0.0dev2
Upvotes: 7
Views: 27745
Reputation: 588
Was trying out AWS DynamoDB samples from Windows CMD prompt... I spent more time figuring out the command, escape characters, quotes, .... than the time I spent on learning DynamoDB itself. Phew!
Just adding the below if it might help anyone, and myself if I end up googling/sfo'ing again!!
Command for Linux Shell
aws dynamodb put-item \
--table-name device_data \
--item \
'{"device_id": {"S": "12345678"}, "datacount": {"N": "1"} , "timestamp": {"N": "1514876999940"}, "temperature1": {"N": "32.78"}, "temperature2": {"N": "21.76"}, "temperature3": {"N": "15.12"}, "temperature4": {"N": "20.22"}, "temperature5": {"N": "14.43"} }'
Command that worked for me in Windows Command Prompt:
aws dynamodb put-item ^
--table-name device_data ^
--item ^
"{\"device_id\": {\"S\": \"12345678\"}, \"datacount\": {\"N\": \"1\"} , \"timestamp\": {\"N\": \"1514876999940\"}, \"temperature1\": {\"N\": \"32.78\"}, \"temperature2\": {\"N\": \"21.76\"}, \"temperature3\": {\"N\": \"15.12\"}, \"temperature4\": {\"N\": \"20.22\"}, \"temperature5\": {\"N\": \"14.43\"} }"
Upvotes: 4
Reputation: 69
If you are using Windows, you can use escape sequence as in the following command to successfully run in AWS CLI as below:
aws textract detect-document-text --document "{\"S3Object\":{\"Bucket\":\"NameOfBucket\",\"Name\":\"NameOfImage\"}}"
Upvotes: 6
Reputation: 270154
That error is being caused by the quotes at the beginning and end of the JSON file.
However, removing them also seems to cause a problem due to the backslashes.
It worked for me (on a Mac, not Windows) when I used this file:
{"ID": {"N":"2"}, "Value": {"S": "From json file with escape characters"}}
Upvotes: 3