无服务器event.body是一个对象,但content-type不是json

时间:2018-12-11 15:15:07

标签: aws-api-gateway serverless-framework serverless aws-serverless

我正在使用无服务器部署我的api;

functions:
  # hello:
  #   handler: index.handler
  #   events:
  #     - http: ANY /
  #     - http: 'ANY {proxy+}'
  addAnnouncement:
    handler: index.handler
    events:
      - http:
          method: POST
          path: /abc/{foo}/cde/efg
          cors: true
          integration: lambda
          request:
            parameters:
              paths:
                foo: true
      - http:
          method: DELETE
          path: /abc/{foo}/cde/efg
          cors: true
          integration: lambda
          request:
            parameters:
              paths:
                foo: true
      - http:
          method: GET
          path: /abc/{foo}/cde/efg
          cors: true
          integration: lambda
          request:
            parameters:
              paths:
                foo: true

我的api路由如下所示;

当我点击api-gateway-url时出现以下错误

{
  "errorMessage": "event.body was an object but content-type is not json",
  "errorType": "Error",
  "stackTrace": [
  "getBody (/var/task/node_modules/serverless-http/lib/request.js:24:13)",
  "new ServerlessRequest (/var/task/node_modules/serverless-http/lib/request.js:44:18)",
  "Promise.resolve.then (/var/task/node_modules/serverless-http/serverless-http.js:30:25)",
"<anonymous>"
]
}

0 个答案:

没有答案