调用 AWS Gateway API:com.amazon.coral.service#SerializationException

hel*_*rld 4 aws-api-gateway

呃,

我正在调用 AWS Api,但我得到了

Endpoint response body before transformations: 
{"__type":"com.amazon.coral.service#SerializationException"}
Endpoint response body before transformations:
{
"__type": "com.amazon.coral.service#SerializationException"
}
Run Code Online (Sandbox Code Playgroud)

同一类型职位的特定职位后出现错误。我已启用详细的 Cloudwatch 日志记录,但它没有为我提供任何其他信息。此外,相关 API 请求正文在转换前后都会被截断。

是否有一些额外的日志选项可供测试?我想我只需要采用 JSON 格式的原始 API 调用并从中删除字段,就可以看看是什么导致了它的崩溃?

小智 7

我在使用 VTL 映射模板直接与 DynamoDB 表集成的 API Gateway REST API 上遇到此错误。我更改映射模板后开始出现错误。

HTTP/2 200

{"__type":"com.amazon.coral.service#SerializationException"}
Run Code Online (Sandbox Code Playgroud)

使用在线“ JSON Validator ”工具检查映射模板 JSON 后,我发现我的模板不是有效的 JSON。(我,在对象列表中有一个额外的字符)。修复模板,使其成为有效的 JSON,修复了错误


hel*_*rld 5

我最终通过在集成请求中提供以下映射模板来修复:

 #set($input = $input.json('$'))
  {
     "input": "$util.escapeJavaScript($input).replaceAll("\\'", "'")",
   "stateMachineArn": "arn:aws:states:xxxxxxxxxxx"
  }
Run Code Online (Sandbox Code Playgroud)

有点令人讨厌的修复,但它有效......