Slack斜杠命令从lambda获取400_client_error

问题描述 投票:0回答:1

我在heroku上主持了一个简单的slack slash命令。我把它移到lambda,但现在它得到了:

Darn - that slash command didn't work (error message: `400_client_error`). Manage the command at 💩.

该错误不提供更多信息,也没有说明失败的原因。

我可以使用curl命中端点并返回看起来像正确格式化json的内容:

curl -X POST \
  https://5hi90e8v8e.execute-api.us-east-2.amazonaws.com/Prod \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Postman-Token: eacb33ee-96ac-457e-a325-9fdc132f808e' \
  -H 'cache-control: no-cache'
{
    "text": "Have suggestions to improve this bot? Message <@UC8R7PA87>",
    "response_type": "in_channel"
}

头:

Date →Sat, 09 Mar 2019 01:12:02 GMT
Content-Type →application/json
Content-Length →922
Connection →keep-alive
x-amzn-RequestId →57cec19a-4208-11e9-924c-89367de80c6d
x-amz-apigw-id →WP_jLFWYiYcFiXg=
X-Amzn-Trace-Id →Root=1-5c8312e1-327ac177db85f799dcd267c1;Sampled=0

我旧的heroku端点的响应:

{
    "response_type": "in_channel",
    "text": "Have suggestions to improve this bot? Message <@UC8R7PA87>"
}

头:

Connection →keep-alive
Server →gunicorn/19.6.0
Date →Sat, 09 Mar 2019 01:01:36 GMT
Content-Type →application/json
Content-Length →946
Via →1.1 vegur

有关如何查找实际错误/如何调试的任何想法?

aws-lambda slack slack-api
1个回答
1
投票

可能是AWS Gateway中的问题以及它如何转换请求。尝试使用:

{
  "method": "$context.httpMethod",
  "body" : $input.json('$'),
  "headers": {
    #foreach($param in $input.params().header.keySet())
    "$param": "$util.escapeJavaScript($input.params().header.get($param))" #if($foreach.hasNext),#end

    #end
  }
}

在Integration Request / Mapping Templates / application / json中进行调试。

© www.soinside.com 2019 - 2024. All rights reserved.