user1484777
user1484777

Reputation: 103

AWS CLI: Error parsing parameter '--item': Expected: '=', received: '"' for input:

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

Answers (3)

Giridhar
Giridhar

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\"} }"
  1. Replaced Back Slash \ with caret ^ --> this is only for breaking the command to next line. No space after caret ^
  2. Replaced Single qoute ' with Double Quote " around the whole JSON
  3. Added Back Slash \ as Escape Char before the Double Quote " inside JSON

Upvotes: 4

Krishty
Krishty

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

John Rotenstein
John Rotenstein

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

Related Questions