Closed IamGroot19 closed 1 year ago
@wiggin77 - Could you help out with Boards API?
@IamGroot19 the Focalboard API docs are here. There is a problem with the publisher not picking up some of the data structs but it will provide a list of APIs and same curl command.
@wiggin77 Yes, I am aware of the docs for focalboard API. But my question was different. I had enabled mattermost boards in the matermost server and tried to make a few API calls (based on the API documentation you had also pointed out). But I am not getting the response I expected.
For eg, the /teams/:teamID/boards
API endpoint provides a response saying (pls chk rhe issue description):
We're having trouble connecting to Mattermost. If refreshing this page (Ctrl+R or Command+R) does not work, please verify that your computer is connected to the internet.
I am not sure which of the following is the case: a) I am making some mistake in the API call b) The documentation is not clear enough c) The integration of focalboard into mattermost has some bug & hence there is an issue with API call.
For referennce, I ran a local setup of mattermost server on the "preview mode" via a docker container. (Also, i ensured that mattermost board was enabled in the server settings).
My apologies if I didnt frame the question clearly in the issue's description.
@IamGroot19 I see the docs have the incorrect URL prefix for running Boards as a plugin. For example:
http://localhost:8065/api/v2/teams/{teamID}/boards
should be http://localhost:8065/plugins/focalboard/api/v2/teams/{teamID}/boards
Also, you'll need to provide CSRF tokens as described here.
@wiggin77 I went thru the article you linked regarding CSRF token & still have trouble making requests. Would appreciate some help.
Obtaining CSRF token
$ curl -i -d '{"login_id":"bsr", "password":"12345"}' -H "X-Requested-With: XMLHttpRequest" http://localhost:8065/api/v4/users/login
HTTP/1.1 200 OK
Content-Type: application/json
Set-Cookie: MMAUTHTOKEN=6xorca7qg3rz3nk4soduqt7gqh; Path=/; Expires=Sat, 11 Feb 2023 07:56:36 GMT; Max-Age=2592000; HttpOnly
Set-Cookie: MMUSERID=tnouobug9tg6xnx354gzjon93r; Path=/; Expires=Sat, 11 Feb 2023 07:56:36 GMT; Max-Age=2592000
Set-Cookie: MMCSRF=gzi675msziyj8dauocmz4g1hjc; Path=/; Expires=Sat, 11 Feb 2023 07:56:36 GMT; Max-Age=2592000
Token: 6xorca7qg3rz3nk4soduqt7gqh
Vary: Accept-Encoding
X-Request-Id: og5t6yypjjdcjqe3cpunhc6qbh
X-Version-Id: 7.5.2.7.5.2.d491c2db3a5411d22519e52c3623ef9e.false
Date: Thu, 12 Jan 2023 07:56:36 GMT
Content-Length: 711
Using CSRF token
// trial 1
$ curl -H "Authorization: Bearer gzi675msziyj8dauocmz4g1hjc" "http://localhost:8065/plugins/focalboard/api/v2/teams/6mnza3dgwiy7785ndk95ohbdsy/boards"
{"error":"checkCSRFToken FAILED","errorCode":400}
// trial 2
$ curl -H "Authorization: Token gzi675msziyj8dauocmz4g1hjc" "http://localhost:8065/plugins/focalboard/api/v2/teams/6mnza3dgwiy7785ndk95ohbdsy/boards"
{"error":"checkCSRFToken FAILED","errorCode":400}
Update (for someone else who stumbles upon similar issue):
After a bit of trial & error, I figured out correct set of headers.:
// Get the CSRF token first
$ curl -i -d '{"login_id":"bsr", "password":"12345"}' -H "X-Requested-With: XMLHttpRequest" http://localhost:8065/api/v4/users/login
HTTP/1.1 200 OK
Content-Type: application/json
Set-Cookie: MMAUTHTOKEN=6xorca7qg3rz3nk4soduqt7gqh; Path=/; Expires=Sat, 11 Feb 2023 07:56:36 GMT; Max-Age=2592000; HttpOnly
Set-Cookie: MMUSERID=tnouobug9tg6xnx354gzjon93r; Path=/; Expires=Sat, 11 Feb 2023 07:56:36 GMT; Max-Age=2592000
Set-Cookie: MMCSRF=gzi675msziyj8dauocmz4g1hjc; Path=/; Expires=Sat, 11 Feb 2023 07:56:36 GMT; Max-Age=2592000
Token: 6xorca7qg3rz3nk4soduqt7gqh
Vary: Accept-Encoding
X-Request-Id: og5t6yypjjdcjqe3cpunhc6qbh
X-Version-Id: 7.5.2.7.5.2.d491c2db3a5411d22519e52c3623ef9e.false
Date: Thu, 12 Jan 2023 07:56:36 GMT
Content-Length: 711
// Then use the csrf + auth token like:
$ curl -H "Authorization: Bearer 6xorca7qg3rz3nk4soduqt7gqh" -H "X-CSRF-Token: gzi675msziyj8dauocmz4g1hjc" -H "X-Requested-With: XMLHttpRequest" "http://localhost:8065/plugins/focalboard/api/v2/teams/6mnza3dgwiy7785ndk95ohbdsy/boards"
Summary
Unable to perform operations on the integrated focalboard via API. Also, no mention of focalboard api in mattermost docs.
Expected behavior
I installed a preview version of mattermost via docker container (from these instructins. Ensured plugin is enabled and mattermost board is enabled. I want to perform operations on the mattermost board via API. For eg, writing a script to migrate our issues from another tool (say phabricator or gitlab issues) to focalboard. But I am unable to find any documentation around this. i tried the API endpoints mentioned in focalboard docs but they are not working either.
Few queries that i tried
Observed behavior (that appears unintentional)
Pls advise with regards how to use API for boards. NOTE: I had previously opened an issue at mattermost-server repo (https://github.com/mattermost/mattermost-server/issues/21981) but was asked to reopen it here