最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - URL didn't respond with value of challenge parameter in Events API in Slack - Stack Overflow

programmeradmin3浏览0评论

I am trying to use the Events API in Slack. However, setting my endpoint to: is giving the error:

the URL didn't respond with the value of the challenge parameter

Slack posts the following:

{
    "token": "Jhj5dZrVaK7ZwHHjRyZWjbDl",
    "challenge": "3eZbrw1aBm2rZgRNFdxV2595E9CY3gmdALWMmHkvFXO7tYXAYM8P",
    "type": "url_verification"
}

Obviously the challenge is a random code.

I have a function in SlackController.php:

public function returnChallenge(Request $request)
    {
        return response()->json(['challenge' => $request->json()->get('challenge')]);
    }

in api.php:

Route::post('slack/events', 'SlackController@returnChallenge');

Since the Laravel and Nginx error log file is empty, I decided to look in Nginx access.log:

"POST /api/slack/events HTTP/1.1" 400 224 "-" "Slackbot 1.0 (+)"

There is no firewall that blocks Slack. What is the issue here?

What I tried:

  • Logging all requests, however Slack doesn't even hit the endpoint.
  • Using a PHP script to rule out any issues with Laravel or weird middleware rules, also no error from Slack.

I followed everything on Slack URL verification to the point, without results.

The endpoint gives a status 200 in Postman and it returns the given challenge in JSON.

I am trying to use the Events API in Slack. However, setting my endpoint to: https://mywebsite/api/slack/events is giving the error:

the URL didn't respond with the value of the challenge parameter

Slack posts the following:

{
    "token": "Jhj5dZrVaK7ZwHHjRyZWjbDl",
    "challenge": "3eZbrw1aBm2rZgRNFdxV2595E9CY3gmdALWMmHkvFXO7tYXAYM8P",
    "type": "url_verification"
}

Obviously the challenge is a random code.

I have a function in SlackController.php:

public function returnChallenge(Request $request)
    {
        return response()->json(['challenge' => $request->json()->get('challenge')]);
    }

in api.php:

Route::post('slack/events', 'SlackController@returnChallenge');

Since the Laravel and Nginx error log file is empty, I decided to look in Nginx access.log:

"POST /api/slack/events HTTP/1.1" 400 224 "-" "Slackbot 1.0 (+https://api.slack/robots)"

There is no firewall that blocks Slack. What is the issue here?

What I tried:

  • Logging all requests, however Slack doesn't even hit the endpoint.
  • Using a PHP script to rule out any issues with Laravel or weird middleware rules, also no error from Slack.

I followed everything on Slack URL verification to the point, without results.

The endpoint gives a status 200 in Postman and it returns the given challenge in JSON.

Share Improve this question edited Mar 17 at 16:17 Richard 5694 silver badges20 bronze badges asked Mar 17 at 11:02 User4543User4543 112 bronze badges 4
  • if postman is working than there is something different on the slack request. try to log the headers sent from both sources, and what HTTP method is being used – kris gjika Commented Mar 17 at 16:15
  • I tried logging ALL requests, including headers. They are not even hitting the endpoint. – User4543 Commented Mar 17 at 16:18
  • where did you try to log? bc in your controller for example is likely too late – kris gjika Commented Mar 17 at 16:20
  • also api.slack/events/url_verification says to respond in plain text not in json – kris gjika Commented Mar 17 at 16:23
Add a comment  | 

1 Answer 1

Reset to default 0

I think you need to use the all method

public function returnChallenge(Request $request)
    {
        return response()->json(['challenge' => $request->all()['challenge']]);
    }

发布评论

评论列表(0)

  1. 暂无评论