Slash command unable to execute API call, works with curl


I have an API on AWS API Gateway that works with all other tools but Slash Commands just gives an error.

Expected behavior

I have an API on AWS Gateway that returns a simple JSON object that I want to use for a Slash Command.
I tried it with different tools, including curl from the machine running Mattermost and they all return the correct result.

Observed behavior

Using the same URL from within a Slash Command just gives me a Cloudfront 403 Error, pasted here from the log without the HTML and without some server details.

Command with a trigger of ‘slashtest’ returned response 403 Forbidden. Details:
The request could not be satisfied.
Bad request.
Generated by cloudfront (CloudFront)
Request ID:

Now, I see that there is a non-mattermost component in the error message, but as no other tool has trouble calling the API I suspect that Mattermost does something on it’s own.
Does someone know how Mattermost calls APIs form inside a slash command? Are any parameters or headers added or changed?

Hi @tuxlover,

The only headers we add are Content-Type (for POST requests) and Accept, so I don’t think those would cause this problem.

Is your slash command using HTTPS? Perhaps you could try setting ServiceSettings.EnableInsecureOutgoingConnections to true in the config.json in case that’s causing problems with making the connection

I actually got it to work shortly before your answer.
It looks like the AWS API Gateway dislikes getting a body on a GET request and after some research I found out that most of the planet considers a body on a GET request a bad idea too.
So, ignoring wether or not the body is bad practice I am now using a POST and it works as expected.

Thanks for answering, though! I hope my findings help someone else as well.

Excellent. Glad to hear it’s working then