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

杀马特。学长 韩版系。学妹 提交于 2021-01-28 05:11:13

问题


#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" ##


回答1:


The way I understand your question I would do :

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

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



来源:https://stackoverflow.com/questions/55546882/how-to-use-if-condition-in-aws-api-gateway-mapping-templates-can-i-use-if-condi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!