Triggering slash command using API

I am developing a plugin that will utilize a slash command, and have some front end components that I want to allow to call that slash command. However, whenever I send a request to the API as shown here, I am given the response containing:

{
    body: (...)
    bodyUsed: false
    headers: Headers {}
    ok: false
    redirected: false
    status: 405
    statusText: "Method Not Allowed"
    type: "basic"
    url: "http://localhost:8065/commands/execute"
}

I’m wondering why it is responding with a 405 status, and what I might do to fix it so that I can trigger the slash command that I have working.

The first step you’ll wanna take here is checking the console, which should give you some more information on what went wrong. On the menu that comes out from the top left, go System Console > Server Logs, and see what went wrong.
Are you doing a POST request with the proper authorization bearer?

Did you ever manage to figure this out? I’m finding myself facing almost exactly the same problem.

I see the following log entry that seems to be the smoking gun, but the user in question actually has system admin permission level, so how can they NOT have permission to create_post?
``
{
“caller”: “web/context.go:118”,
“err_where”: “Permissions”,
“error”: “Permissions: You do not have the appropriate permissions., userId=jdpuac7fkprtmnmhx7tp1co7qc, permission=create_post”,
“http_code”: 403,
“ip_addr”: “x.x.x.x”,
“level”: “debug”,
“method”: “POST”,
“msg”: “You do not have the appropriate permissions.”,
“path”: “/api/v4/commands/execute”,
“request_id”: “3jkrz8feyprd38fn46s4tnuznc”,
“timestamp”: “2025-10-19 16:12:56.704 Z”,
“user_id”: “jdpuac7fkprtmnmhx7tp1co7qc”
}
```

Just as followup, the problem was due to attempting this from a DM conversation. When we switched to a regular channel it started working as expected.

I don’t see why it would matter, but it did.

1 Like