Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamoDB putitem do not work? #11

Open
xiuliren opened this issue Feb 21, 2018 · 2 comments
Open

DynamoDB putitem do not work? #11

xiuliren opened this issue Feb 21, 2018 · 2 comments

Comments

@xiuliren
Copy link

xiuliren commented Feb 21, 2018

I am not sure whether I am doing it correctly or not.

strDict=Dict("psd_segid"=>"45")
@show strDict
@show typeof(strDict)
DynamoDB.put_item(AWS_CREDENTIAL; TableName=TABLE_NAME, Item=strDict)

according to the documentation, the item type is indeed Dict{String,String}, but I still get the following error:

strDict = Dict("psd_segid"=>"45")
typeof(strDict) = Dict{String,String}
SerializationException -- Unexpected value type in payload
HTTP.ExceptionRequest.StatusError(400, HTTP.Messages.Response:
"""
HTTP/1.1 400 Bad Request
Server: Server
Date: Wed, 21 Feb 2018 19:55:53 GMT
Content-Type: application/x-amz-json-1.0
Content-Length: 105
Connection: keep-alive
x-amzn-RequestId: OHI4FMSR0F8HVRPPLJ5LTUFREFVV4KQNSO5AEMVJF66Q9ASUAAJG
x-amz-crc32: 2551049119

{"__type":"com.amazon.coral.service#SerializationException","Message":"Unexpected value type in payload"}""")


Stacktrace:
 [1] #request#1(::Array{Any,1}, ::Function, ::Type{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}, ::HTTP.URIs.URI, ::Vararg{Any,N} where N) at /usr/people/jingpeng/.julia/v0.6/HTTP/src/ExceptionRequest.jl:22
 [2] (::HTTP.#kw##request)(::Array{Any,1}, ::HTTP.#request, ::Type{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}, ::HTTP.URIs.URI, ::HTTP.Messages.Request, ::String) at ./<missing>:0
 [3] #request#1(::VersionNumber, ::String, ::Void, ::Void, ::Array{Any,1}, ::Function, ::Type{HTTP.MessageRequest.MessageLayer{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}}, ::String, ::HTTP.URIs.URI, ::Array{Pair{SubString{String},SubString{String}},1}, ::String) at /usr/people/jingpeng/.julia/v0.6/HTTP/src/MessageRequest.jl:44
 [4] (::HTTP.#kw##request)(::Array{Any,1}, ::HTTP.#request, ::Type{HTTP.MessageRequest.MessageLayer{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}}, ::String, ::HTTP.URIs.URI, ::Array{Pair{SubString{String},SubString{String}},1}, ::String) at ./<missing>:0
 [5] macro expansion at /usr/people/jingpeng/.julia/v0.6/AWSCore/src/http.jl:31 [inlined]
 [6] macro expansion at /usr/people/jingpeng/.julia/v0.6/Retry/src/repeat_try.jl:206 [inlined]
 [7] http_request(::Dict{Symbol,Any}) at /usr/people/jingpeng/.julia/v0.6/AWSCore/src/http.jl:22
 [8] macro expansion at /usr/people/jingpeng/.julia/v0.6/AWSCore/src/AWSCore.jl:418 [inlined]
 [9] macro expansion at /usr/people/jingpeng/.julia/v0.6/Retry/src/repeat_try.jl:206 [inlined]
 [10] do_request(::Dict{Symbol,Any}) at /usr/people/jingpeng/.julia/v0.6/AWSCore/src/AWSCore.jl:396
 [11] #service_json#8(::Array{Any,1}, ::Function, ::Dict{Symbol,Any}) at /usr/people/jingpeng/.julia/v0.6/AWSCore/src/AWSCore.jl:263
 [12] (::AWSCore.#kw##service_json)(::Array{Any,1}, ::AWSCore.#service_json, ::Dict{Symbol,Any}) at ./<missing>:0
 [13] (::AWSSDK.DynamoDB.#kw##put_item)(::Array{Any,1}, ::AWSSDK.DynamoDB.#put_item, ::Dict{Symbol,Any}) at ./<missing>:0
 [14] include_string(::String, ::String) at ./loading.jl:522
@xiuliren
Copy link
Author

It turns out that my item type is not correct, I find it out from python documentation!

strDict=Dict("psd_segid"=>Dict("S"=>"45"))

@samoconnor
Copy link
Contributor

samoconnor commented Feb 21, 2018

The example in the the julia documentation also has the "S" =>

[
    "Item" => [
        "AlbumTitle" => [
            "S" => "Somewhat Famous"
        ],
        "Artist" => [
            "S" => "No One You Know"
        ],
        "SongTitle" => [
            "S" => "Call Me Today"
        ]
    ],
    "ReturnConsumedCapacity" => "TOTAL",
    "TableName" => "Music"
]

... and the JSON API definition has the detail of that: https://github.com/aws/aws-sdk-js/blob/master/apis/dynamodb-2012-08-10.normal.json#L508

It seems that at this point the JSON spec defines the argument type as "map", and in my doc generator I incorrectly document all "map" items as Dict{String,String}.

It shouldn't be too difficult to update the doc generator.

Thanks for trying this out and reporting the problems!!

@samoconnor samoconnor reopened this Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants