Aws lambda API网关:can';t在映射模板中提取原始实体
我需要在lambda函数web钩子中提取原始主体。 我尝试了一些模板配置,以提取原始身体。在选项->集成请求中: 我正在添加不同的模板:Aws lambda API网关:can';t在映射模板中提取原始实体,aws-lambda,aws-api-gateway,Aws Lambda,Aws Api Gateway,我需要在lambda函数web钩子中提取原始主体。 我尝试了一些模板配置,以提取原始身体。在选项->集成请求中: 我正在添加不同的模板: #set($allParams = $input.params()) { "raw": "$input.body", "body-json" : $input.json('$'), "params" : { #foreach($type in $allParams.keySet
#set($allParams = $input.params())
{
"raw": "$input.body",
"body-json" : $input.json('$'),
"params" : {
#foreach($type in $allParams.keySet())
#set($params = $allParams.get($type))
"$type" : {
#foreach($paramName in $params.keySet())
"$paramName" : "$util.escapeJavaScript($params.get($paramName))"
#if($foreach.hasNext),#end
#end
}
#if($foreach.hasNext),#end
#end
},
"stage-variables" : {
#foreach($key in $stageVariables.keySet())
"$key" : "$util.escapeJavaScript($stageVariables.get($key))"
#if($foreach.hasNext),#end
#end
},
"context" : {
"account-id" : "$context.identity.accountId",
"api-id" : "$context.apiId",
"api-key" : "$context.identity.apiKey",
"authorizer-principal-id" : "$context.authorizer.principalId",
"caller" : "$context.identity.caller",
"cognito-authentication-provider" : "$context.identity.cognitoAuthenticationProvider",
"cognito-authentication-type" : "$context.identity.cognitoAuthenticationType",
"cognito-identity-id" : "$context.identity.cognitoIdentityId",
"cognito-identity-pool-id" : "$context.identity.cognitoIdentityPoolId",
"http-method" : "$context.httpMethod",
"stage" : "$context.stage",
"source-ip" : "$context.identity.sourceIp",
"user" : "$context.identity.user",
"user-agent" : "$context.identity.userAgent",
"user-arn" : "$context.identity.userArn",
"request-id" : "$context.requestId",
"resource-id" : "$context.resourceId",
"resource-path" : "$context.resourcePath"
}
}
或者只是:
{"raw": "$util.escapeJavaScript($input.body)"}
但是“event.raw”总是没有定义