9

While putting below JSON in dynamo DB using AWS CLI with below command:

aws dynamodb put-item --table-name ScreenList --item file://tableName.json

I am getting Parameter validation failed Exception.I have gone rigorously through AWS docs but failed to find example to insert a complicated json.Every small help is welcome.

The updated Json :

{
  "itemName": {
    "S": "SCREEN_LIST"
  },
  "productName": {
    "S": "P2P_MOBITEL"
  },
  "screenList": {
    "L": [
      {
        "menu": {
          "L": [
            {
              "M": {
                "menuId": {
                  "N": "1"
                },
                "menuText": {
                  "S": "ENG_HEADING"
                },
                "menuType": {
                  "S": "Dynamic"
                }
              }
            }
          ]
        },
        "M": {
          "screenFooter": {
            "S": "F_LANGUAGE_CHANGE"
          },
          "screenHeader": {
            "S": "H_LANGUAGE_CHANGE"
          },
          "screenId": {
            "S": "LANGUAGE_CHANGE"
          },
          "screenType": {
            "S": ""
          }
        }
      }
    ]
  }
}
1
  • I've updated the answer, please take a look. Commented Aug 3, 2017 at 16:21

1 Answer 1

11

It seems that you are defining complex types incorrectly. According to AWS documentation you should define a list like this:

"L": ["Cookies", "Coffee", 3.14159]

and a map should be defined like this:

"M": {"Name": {"S": "Joe"}, "Age": {"N": "35"}}

which means that a menu map should be defined like this:

"menu": { 
  "L": [
    {
      "M": {
        "menuId": {"N" :"1"},
        "menuText": {"S" :"PACKS_SCREEN"},
        "menuType": {"S" :"Dynamic"}
      }
    }
  ]
}

Notice the "M" and "L" attributes.

You should change the rest of your JSON in a similar fashion.

You can find full JSON definition here in the Options section.

UPDATE

Now your list definition is incorrect. You have:

   "screenList":{  
      "L":[  
         {  
            "menu":{ ... },
            "M":{ ... }
         }
      ]
   }

While it should be:

   "screenList":{  
      "L":[  
         {  
            "M":{ ... }   
         },
         {  
            "M":{ ... }   
         },
      ]
   }
Sign up to request clarification or add additional context in comments.

5 Comments

Again it says was parameter validation Exception...it says unknown parameter "menu".It should be must be one of :S,N,B,M,L.
I am not sure if this is an issue with StackOverflow or with your JSON, but it does not pass JSON validation. Try to ensure that this is valid JSON first (e.g. you can use an online formatter: jsonformatter.org)
Also, could you update JSON in your question? It's hard to read it in the comment section.
It worked , but here I need name of map.The entries are added in the table along with the "L","M".I want to replace 2 maps "M","M" in List "L " with some name so that i can retrieve easily and my table becomes readable.
You can have item names in a list. You can either make "screenList" a map (I guess it would be "screenMap" then), or you can store a nested map in a list something like [{"menu": {}, "else": {}}]. Mind that you need to convert this into DynamoDB format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.