Fork me on GitHub

I'm trying to save multiple records to DynamoDB using cognitect-labs/aws-api (as per example found here but while it seems that it's set up the same as the examples I'm clearly doing something wrong. The image shows "user errors" which are described as 400 errors due to poor formatting. My code is similar to this:

(def ddb (aws/client {:api :dynamodb}))

(defn save-stuff []
  (aws/invoke ddb {:op :BatchWriteItem,
                             {"twitter-id" {:S "1232539310127140864"}, "lang" {:S "en"}}}}
                             {"twitter-id" {:S "1232539306297823232"}, "lang" {:S "en"}}}}]}}}
Any idea what I'm doing wrong?


@U0Q032M8B what is the output of invoking save-stuff? Also, what is the metadata of that output? (meta (save-stuff)).


@U0ENYLGTA Oh sorry I should have mentioned that (late night with a sick kid put it out of my mind). There is no console output. The metadata for the fn is:

 {:request-method :post,
  :scheme :https,
  :server-port 443,
  :uri "/",
  {"x-amz-date" "20200226T154816Z",
   "x-amz-target" "DynamoDB_20120810.BatchWriteItem",
   "content-type" "application/x-amz-json-1.0",
   "host" "",
   "x-amz-security-token" [really long token],
   "authorization" [authorization-stuff]},
  #object[java.nio.HeapByteBuffer 0x587a1cfb "java.nio.HeapByteBuffer[pos=0 lim=46 cap=46]"],
  :server-name ""},
 {:status 400,
  {"server" "Server",
   "connection" "keep-alive",
   "x-amz-crc32" "3101795386",
   "content-length" "179",
   "date" "Wed, 26 Feb 2020 15:48:16 GMT",
   "content-type" "application/x-amz-json-1.0"},
  #object[.BufferedInputStream 0x5fa23c ".BufferedInputStream@5fa23c"]}}


FYI: I'm also not setting up the tables in the code, and the lang field doesn't exist on the table yet. Not sure if that's pertinent or not.


I tried BatchWriteItem with a missing attribute and got back error information.


A missing attribute? Since DynamoDB is a schema-less db, shouldn't it not matter what objects you put in it (as long as it has the required id specified for the table)? (Meaning you can add attributes or leave them off as needed.)


If I comment out the "Subject" attribute when creating the "Thread" table in the ddb example (, then I get

{:__type "",
  :message "Provided list of item keys contains duplicates",
  :cognitect.anomalies/category :cognitect.anomalies/incorrect}
back from WriteBatchItem. Not clear on why that is yet, but the point is that I'm getting some feedback and you're saying you're not getting any.


Correct. I'm calling it from AWS Lambda, but I'm still expecting something.


Please submit an issue for this, and include all the dependency information, etc.


Okay, will do when I'm done with work or during lunch.

👍 4

An unrelated question I had that I couldn't find any examples for, when adding a sub-map is the proper syntax to add a vector of attribute maps? Like this:

{"PutRequest" {"Item" {"id" {:S id}
                       "x" {:M [{:height {:N "16"}} {:name {:S "John"}}]}}}


That's json from examples from AWS. In aws-api, keys like "L" need to be keywords like :L .


Oh, okay. That thought that was "L" for "List". Yes that helps.

👍 4

No, thank you! 🙂