I have made a table "Blog" in dynamodb
.
I want to insert the 2 parameters "title" and "content" in it which I am fetching from a HTML form.
The parameters "blogContent" and "blogTitle" seem to be valid when I print these 2 in the console.
But when I am inserting them in the table i get the error:
"One or more parameter values were invalid: Missing the key id in the item status code: 400, request id: 71CT5IPM1SIDKSDVUGWGUCSJ77VV4KQNSO5ZAMVJF66Q9ASUAAJG"
type Item struct {
id int
content string
bodycontentversion string
claps int
comments int
imageid int
title string
views int
}
func awsblog() {
sess, err := session.NewSession(&aws.Config{
Region: aws.String("us-east-1")},
)
svc := dynamodb.New(sess)
item := Item{
id: 1234,
content: blogContent,
bodycontentversion: "abcd",
claps: 5,
comments: 10,
imageid: 1234,
title: blogTitle,
views: 10,
}
av, err := dynamodbattribute.MarshalMap(item)
if err != nil {
fmt.Println("Got error marshalling new item:")
fmt.Println(err.Error())
os.Exit(1)
}
tableName := "Blog"
input := &dynamodb.PutItemInput{
Item: av,
TableName: aws.String(tableName),
}
_, err = svc.PutItem(input)
if err != nil {
fmt.Println("Got error calling PutItem:")
fmt.Println(err.Error())
os.Exit(1)
}
fmt.Println("Successfully updated '")
}