Quantcast
Channel: Mattermost Discussion Forums - Latest posts
Viewing all articles
Browse latest Browse all 25778

Can't authenticate via curl after setting up docker evaluation version

$
0
0

Oh sorry, I should've asked what version of Mattermost you were running. Our API documentation is already limited for the current version, but it's practically nonexistent for older ones.

If you're just using the instance for a trial run, I'd recommend deleting the existing preview instance if possible and starting out with one running Mattermost 3.2. There's some pretty significant changes since 1.4, particularly in Mattermost 3.0, that make it difficult to upgrade from pre-3.0.

Mattermost 3.2

If you switch to Mattermost 3.2, we provide a Javascript driver and a Go driver to make interacting with Mattermost easier than with the command line. If you're not using either of those, the following API calls will log in an existing user and create a channel on a team that they're already a member of:

1) Log in

curl -i -d '{"login_id:":"example@example.com","password":"PASSWORD"}' http://example.com:8065/api/v3/users/login

And copy the authentication token from the line that looks like

Token: TOKEN

2) List the user's teams to get the ID of the team to create the channel on

curl -i -H 'Authorization Bearer TOKEN' http://example.com:8065/api/v3/users/teams/all

That will return a dictionary of the user's teams. You'll want to get the id field of one of your teams

{"TEAM_ID":{"id":"TEAM_ID", "name": "yourteamhere", ...}}

3) Create the channel

curl -i -H 'Authorization: Bearer TOKEN' -d '{"name": "new-channel", "team_id": "TEAM_ID", "type": "O"}' http://example.com:8065/api/v3/teams/TEAM_ID/channels/create

Mattermost 1.4

It's been a while since I've looked at the old API, and I don't have a 1.4 instance available to test them on at this moment, but these steps should create the channel for you.

1) Log in to get the token

curl -i -d '{"name":"springshot","email:":"guy.argo@springshot.com","password":"******"}' http://racerslounge.chat:8065/api/v1/users/login

2) Instead of getting the team ID from a separate API call, it'll be available as part of the previously returned user object

{"id": "abcd1234", "team_id": "TEAMID", ...}

3) Create the channel, same as above, but using the v1 api version

curl -i -H 'Authorization: Bearer TOKEN' -d '{"name": "new-channel", "team_id": "TEAM_ID", "type": "O"}' http://example.com:8065/api/v1/teams/TEAM_ID/channels/create

Viewing all articles
Browse latest Browse all 25778

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>