Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use IF condition in AWS Api gateway mapping templates. can i use if condition without using foreach?

#if($inputRoot.objectType == 'Test'), "TableName": "StudentTests", #else,"TableName": "UserActions", #end

if use if condition i got an error in postman link ## "__type": "com.amazon.coral.service#SerializationException" ##

like image 286
katik S Avatar asked Oct 29 '25 07:10

katik S


1 Answers

The way I understand your question I would do :

#if($inputRoot.objectType == "Test")
    #set($tableName = "StudentTests"
#else
    #set($tableName = "UserActions"
#end

{
    "TableName": "$tableName",
    "Key": ...
}

like image 141
BTL Avatar answered Oct 31 '25 01:10

BTL