creators
(Ronald)
February 28, 2023, 8:32am
1
I’m relatively new to using the HTTP module in N8n, hope I’ve got most things right.
First I went into my self hosted Mattermost to enable API access, so that in my settings I can create a personal API key.
Then I go into N8n to create a HTTP Module.
I’ve decided to start with getting all the cards from a board.
https://htmlpreview.github.io/?https://github.com/mattermost/focalboard/blob/main/server/swagger/docs/html/index.html#api-Default-getCards
So I search for the board ID by going to my website and select the string from the url like this:
https://website.com/boards/team/**ib19zocauida40cgqrfhkq7doo**/btn79n8nd88eimb5348a4co15er/vjcbzjwsm37n4deehwzatazxshc
I set Method to GET and URL to:
https://website.com/api/v2/boards/ib19zocauida38cgqrfhkq7doo/cards
(website.com is used as a placeholder for my own domain)
Then I set Authentication to Generic Credential Type with Header Auth.
In the Header Auth I set
Name: Authorization
Value: {{personal api key}}
But then I get this kind of error in which I don’t know if it’s authentication that goes wrong or something else:
{“status”:“rejected”,“reason”:{“message”:“404 - "{\"id\":\"api.context.404.app_error\",\"message\":\"Sorry, we could not find the page.\",\"detailed_error\":\"There doesn’t appear to be an api call for the url=‘/api/v2/boards/ib19zocauida33cgqrfhkq7doo/cards’. Typo? are you missing a team_id or user_id as part of the url?\",\"status_code\":404}"”,“name”:“Error”,“stack”:“Error: 404 - "{\"id\":\"api.context.404.app_error\",\"message\":\"Sorry, we could not find the page.\",\"detailed_error\":\"There doesn’t appear to be an api call for the url=‘/api/v2/boards/ib19zocauida33cgqrfhkq7doo/cards’. Typo? are you missing a team_id or user_id as part of the url?\",\"status_code\":404}"\n at createError (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/createError.js:16:15)\n at settle (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/core/settle.js:17:12)\n at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/n8n/node_modules/axios/lib/adapters/http.js:269:11)\n at IncomingMessage.emit (node:events:525:35)\n at IncomingMessage.emit (node:domain:489:12)\n at endReadableNT (node:internal/streams/readable:1358:12)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)”}}
agriesser
(Alexander Griesser)
March 1, 2023, 8:27am
2
Hi @creators ,
the path is a bit different, the documentation unfortuantely only refers to focalboard as a standalone product (it’s being integrated into the product at the moment, so things like that are still in the works).
When boards are running as a plugin, the URL to access the API needs to be the plugin API URL, which is https://website.com/plugions/focalboard/api/v2/
- can you try that?
Please note that you will also need a CSRF token, check out the latest comment in this GitHub issue:
opened 06:26AM - 04 Jan 23 UTC
closed 11:23AM - 18 Jan 23 UTC
Bug
#### Summary
Unable to perform operations on the integrated focalboard via API.… Also, no mention of focalboard api in [mattermost docs](https://api.mattermost.com/).
#### Expected behavior
I installed a preview version of mattermost via docker container ([from these instructins](https://docs.mattermost.com/install/install-docker.html#preview-mattermost-using-docker). 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](https://htmlpreview.github.io/?https://github.com/mattermost/focalboard/blob/main/server/swagger/docs/html/index.html#examples-Default-getBoards-0-python) but they are not working either.
Few queries that i tried
```
// query related to teams (from mattermost api)
$ curl -X GET -H "Authorization: Bearer wjd5jd9amby7bd59ye4cgo3egy" "http://127.0.0.1:8065/api/v4/teams"
[{"id":"6mnza3dgwiy7785ndk95ohbdsy","create_at":1672779224457,"update_at":1672779224457,"delete_at":0,"display_name":"sem","name":"sem","description":"","email":"trial@gmail.com","type":"O","company_name":"","allowed_domains":"","invite_id":"ukwofmfxn3yo389cngyrgouz9y","allow_open_invite":false,"scheme_id":null,"group_constrained":null,"policy_id":null,"cloud_limits_archived":false}]
// few queries related to boards
$ curl -X GET -H "Authorization: Bearer wjd5jd9amby7bd59ye4cgo3egy" "http://127.0.0.1:8065/teams/6mnza3dgwiy7785ndk95ohbdsy/boards"
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><meta name="robots" content="noindex, nofollow"><meta name="referrer" content="no-referrer"><title>Mattermost</title><meta name="mobile-web-app-capable" content="yes"><meta name="application-name" content="Mattermost"><meta name="format-detection" content="telephone=no"><link rel="icon" type="image/png" href="/static/images/favicon/favicon-default-16x16.png" sizes="16x16"><link rel="icon" type="image/png" href="/static/images/favicon/favicon-default-24x24.png" sizes="24x24"><link rel="icon" type="image/png" href="/static/images/favicon/favicon-default-32x32.png" sizes="32x32"><link rel="icon" type="image/png" href="/static/images/favicon/favicon-default-64x64.png" sizes="64x64"><link rel="icon" type="image/png" href="/static/images/favicon/favicon-default-96x96.png" sizes="96x96"><link rel="stylesheet" class="code_theme"><style>.error-screen{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;padding-top:50px;max-width:750px;font-size:14px;color:#333;margin:auto;display:none;line-height:1.5}.error-screen h2{font-size:30px;font-weight:400;line-height:1.2}.error-screen ul{padding-left:15px;line-height:1.7;margin-top:0;margin-bottom:10px}.error-screen hr{color:#ddd;margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.error-screen-visible{display:block}</style><meta http-equiv="Content-Security-Policy" content="script-src 'self' cdn.rudderlabs.com/ js.stripe.com/v3"><script defer="defer" src="/static/main.94bef8661903342eb099.js"></script><meta name="apple-mobile-web-app-title" content="Mattermost" /><meta name="apple-mobile-web-app-capable" content="yes" /><meta name="apple-mobile-web-app-status-bar-style" content="default" /><link rel="apple-touch-icon" sizes="76x76" href="/static/icon_76x76.png" /><link rel="apple-touch-icon" sizes="72x72" href="/static/icon_72x72.png" /><link rel="apple-touch-icon" sizes="60x60" href="/static/icon_60x60.png" /><link rel="apple-touch-icon" sizes="57x57" href="/static/icon_57x57.png" /><link rel="apple-touch-icon" sizes="152x152" href="/static/icon_152x152.png" /><link rel="apple-touch-icon" sizes="144x144" href="/static/icon_144x144.png" /><link rel="apple-touch-icon" sizes="120x120" href="/static/icon_120x120.png" /><link rel="manifest" href="/static/manifest.json" /></head><body class="font--open_sans enable-animations"><div id="root"><div class="error-screen"><h2>Cannot connect to Mattermost</h2><hr/><p>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.</p><br/></div><div class="loading-screen" style="position:relative"><div class="loading__content"><div class="round round-1"></div><div class="round round-2"></div><div class="round round-3"></div></div></div></div><div id="root-portal"></div><noscript>To use Mattermost, please enable JavaScript.</noscript></body></html>
$ curl -X GET -H "Authorization: Bearer wjd5jd9amby7bd59ye4cgo3egy" "http://127.0.0.1:8065/api/v2/teams/6mnza3dgwiy7785ndk95ohbdsy/boards"
{"id":"api.context.404.app_error","message":"Sorry, we could not find the page.","detailed_error":"There doesn't appear to be an api call for the url='/api/v2/teams/6mnza3dgwiy7785ndk95ohbdsy/boards'. Typo? are you missing a team_id or user_id as part of the url?","status_code":404}
$ curl -X GET -H "Authorization: Bearer wjd5jd9amby7bd59ye4cgo3egy" "http://127.0.0.1:8065/api/v4/teams/6mnza3dgwiy7785ndk95ohbdsy/boards"
{"id":"api.context.404.app_error","message":"Sorry, we could not find the page.","detailed_error":"There doesn't appear to be an api call for the url='/api/v4/teams/6mnza3dgwiy7785ndk95ohbdsy/boards'. Typo? are you missing a team_id or user_id as part of the url?","status_code":404}bharath@tpx13:~/Documents/mnet_specific/SEM/sem-codebase/phab-migration/mattermost$
```
#### 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
creators
(Ronald)
March 2, 2023, 8:13am
3
Hi @agriesser ,
Ah yes that path gives back data, allthough it’s the same empty data as mentioned in that github card. So I’m getting closer
Would I then just copy paste that set of headers code as “Using JSON” or “Fields” (fields with Name and Value)?
This is something I find a bit hard, but maybe that’s just on me needing to learn n8n better
Thanks anyway, appreciate your help!