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.
- 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
1 Answer
Reset to default 0I think you need to use the all method
public function returnChallenge(Request $request)
{
return response()->json(['challenge' => $request->all()['challenge']]);
}