收到错误消息:“ url”参数必须为字符串类型。尝试发布到Heroku上托管的Slack机器人时收到未定义的类型

我正在尝试使用此repo开发和启动Slack机器人。除了在Heroku上部署之外,我没有进行任何自定义。

我已经完成所有设置,并且我相信它会按预期运行,但是,当我向我的应用发布请求时,出现以下错误:TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received type undefined

以下是完整的错误日志:

2020-01-24T20:44:59.024897+00:00 heroku[router]: at=info method=POST path="/incoming" host=bot-name.herokuapp.com request_id=e5367452-5894-434d-b7e7-15c024480cf0 fwd="34.223.105.71" dyno=web.1 connect=1ms service=35ms status=400 bytes=235 protocol=https
2020-01-24T20:51:31.327412+00:00 app[web.1]: TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received type undefined
2020-01-24T20:51:31.327426+00:00 app[web.1]:     at validateString (internal/validators.js:112:11)
2020-01-24T20:51:31.327428+00:00 app[web.1]:     at Url.parse (url.js:155:3)
2020-01-24T20:51:31.327431+00:00 app[web.1]:     at Object.urlParse [as parse] (url.js:150:13)
2020-01-24T20:51:31.327433+00:00 app[web.1]:     at dispatchHttpRequest (/app/node_modules/axios/lib/adapters/http.js:67:22)
2020-01-24T20:51:31.327436+00:00 app[web.1]:     at new Promise (<anonymous>)
2020-01-24T20:51:31.327438+00:00 app[web.1]:     at httpAdapter (/app/node_modules/axios/lib/adapters/http.js:20:10)
2020-01-24T20:51:31.327440+00:00 app[web.1]:     at dispatchRequest (/app/node_modules/axios/lib/core/dispatchRequest.js:59:10)
2020-01-24T20:51:31.327442+00:00 app[web.1]:     at processTicksAndRejections (internal/process/task_queues.js:94:5) {
2020-01-24T20:51:31.327444+00:00 app[web.1]:   code: 'ERR_INVALID_ARG_TYPE'
2020-01-24T20:51:31.327447+00:00 app[web.1]: }

我不明白错误的含义/程序想要什么。我应该在有效负载中传递其他网址吗?

这是应用程序中处理此部分的部分:

app.post('/incoming',(req,res) => {
  debug('an incoming ticket was received');
  Ticket.fromExternal(req.body)
    .then((ticket) => ticket.postToChannel())
    .then(() => {
      res.sendStatus(200);
    })
    .catch((error) => {
      console.log(error)
      debug(`an error occurred creating the ticket: ${error.message}`);
      res.status(400).send('The ticket was not created');
    });
});

我很乐意在需要的地方提供更多信息,但我在这里迷路了,不确定要解决此问题的必要性,或更不确定是我做错了什么。您可能会说,这对我来说是全新的。

这是我从HTTP帖子获得的响应:

{
    "response": {
        "status_code": 400,"headers": {
            "server": "Cowboy","connection": "close","x-powered-by": "Express","content-type": "text/html; charset=utf-8","content-length": "26","etag": "W/\"1a-vV63UJ4QvBHXPkXtRjN8HhDrha0\"","date": "Fri,24 Jan 2020 21:07:50 GMT","via": "1.1 vegur"
        },"body": "The ticket was not created"
    }
}

我正在使用第三方SAAS平台发送POST请求。是Tray.io。

这是我要发送的有效负载。不知道如果我想念什么。票证信息是回购协议中详述的通用消息。

{
    "body": {
        "raw": "{\n  \"id\": \"1234\",\n  \"link\": \"https://somehelpdesk.localhost\",\n  \"title\": \"Test ticket\",\n  \"description\": \"Oh no! Something went wrong and now everything is on fire :fire:\",\n  \"requester\": \"Leia\",\n  \"status\": \"Open\",\n  \"agent\": \"Chewy\",\n  \"priority\": \"High\"\n}"
    },"queries": [],"headers": [
        {
            "key": "Content-Type","value": "application/json"
        }
    ],"auth": {},"follow_redirect": false,"parse_response": "true","url": "https://membership-slack-bot.herokuapp.com/incoming","reject_unauthorized": true,"tls": {}
}
timeyy 回答:收到错误消息:“ url”参数必须为字符串类型。尝试发布到Heroku上托管的Slack机器人时收到未定义的类型

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2715808.html

大家都在问