Search code examples
amazon-web-servicesaws-api-gateway

AWs API Gateway Mapping Template Invalid


I'm starting a Journey with API Templates, and this is my actual question, but it's answered with "Don't use mapping templates, put logic in client or lambda".
Before even getting that far I'm tried the mapping template from the AWS Blog for Using Amazon API Gateway as a proxy for DynamoDB

In the integration response I paste the text from the blog:

#set($inputRoot = $input.path('$'))
{
    "comments": [
        #foreach($elem in $inputRoot.Items) {
            "commentId": "$elem.commentId.S",
            "userName": "$elem.userName.S",
            "message": "$elem.message.S"
        }#if($foreach.hasNext),#end
    #end
    ]
}

Validation fails with

Validation Result: warnings : [], errors : [Invalid content type specified: #set($inputRoot = $input.path('$')) { "comments": [ #foreach($elem in $inputRoot.Items) { "commentId": "$elem.commentId.S", "userName": "$elem.userName.S", "message": "$elem.message.S" }#if($foreach.hasNext),#end #end ] }]

I tried the answer from this question get the same error.


Solution

  • This was operator error. it was in the error message [Invalid content type specified: I was trying to put the cone into the field for content/type.