簡體   English   中英

AWS Api網關發布到DynamoDB

[英]AWS Api Gateway Post to DynamoDB

我需要響應正文模板的幫助。 我直接使用API​​Gateway在dynamoDB中使用POST到“ PutItem”(無lambda)。

已成功添加新項目,但響應為200空

我需要的是1-新行數據2-狀態3-消息

{
  "data": [],
  "status": "Success",
  "message": "Updated Succesfully"
}

不使用lambda ...這可能嗎?

我嘗試了很多東西

#set($inputRoot = $input.path('$'))
{"templateId": "$elem.templateId.S",
"templateFileName": "$elem.templateFileName.S"}

但顯示為空。

這是我運行Test @API Gateway時的日志

UTC 2018年2月17日星期六06:22:18:轉換后的端點請求主體:

{ 
    "TableName": "xyz-mobilehub-9260364_Template_Table",
    "Item": {
    "templateId": {
            "S": "APIGateway"
            },
        "templateFileName": {
            "S": "breaking-news-story-01-18-2016"
            },
        "templateName": {
            "S": "Just Saying Thank You"
        },
        "templateType": {
            "S": "I really enjoyed this story!!"
        }
    }
}

UTC 2018年2月17日星期六:22:18:發送請求到https://dynamodb.us-east-1.amazonaws.com/?Action=PutItem UTC 2018年2月17日星期六6:22:18已收到響應。 集成延遲:33毫秒,UTC 2018年2月17日星期六:06:22:18:轉換之前的端點響應正文:{} UTC 2018年2月17日6:22:18星期六:端點響應標頭:{服務器=服務器,連接=保持活動, x-amzn-RequestId = RE631UNS84TACTMP4TE752UK0BVV4KQNSO5AEMVJF66Q9ASUAAJG,x-amz-crc32 = 2745614147,Content-Length = 2,Date = Sat,17 Feb 2018 06:22:17 GMT,Content-Type = application / x-amz-json-1.0} UTC 2018年2月17日星期六06:22:18:轉換后的方法響應主體:

{
"templateId": "",
"templateFileName": "",
}

世界標准時間2018年2月17日星期六6:22:18:方法響應標頭:{X-Amzn-Trace-Id = Root = 1-5a87ca19-62a291f9a923480f5c62884f,Content-Type = application / json}世界標准時間2018年2月17日6:22:18 :成功完成執行時間2018年2月17日星期六世界標准時間(UTC):方法完成,狀態:200

轉到API網關中的“集成響應”,然后以所需的方式給出響應。 請看下面的截圖,

在此處輸入圖片說明

選擇集成響應,

在此處輸入圖片說明

在Generate Template下提供您的JSON數據

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM