diff --git a/REST-API-Boards.md b/REST-API-Boards.md index 91125f5..7143a40 100644 --- a/REST-API-Boards.md +++ b/REST-API-Boards.md @@ -18,8 +18,50 @@ curl -H "Authorization: Bearer t7iYB86mXoLfP_XsMegxF41oKT7iiA9lDYiKVtXcctl" \ -d '{ "action": "takeOwnership" }' ``` -## Board colors +## Create board + +Required: +- "title":"Board title here" +- "owner":"ABCDE12345" <= User ID in Wekan. Not username or email. + +Optional, and defaults: +- "isAdmin": "true" +- "isActive": "true" +- "isNoComments": "false" +- "isCommentOnly": "false" +- "permission": "private" <== Set to "public" if you want public Wekan board +- "color": "belize" <== Board color: belize, nephritis, pomegranate, pumpkin, wisteria, midnight. + +Wekan logo + +Example: +``` +curl -H "Authorization: Bearer t7iYB86mXoLfP_XsMegxF41oKT7iiA9lDYiKVtXcctl" \ + -H "Content-type:application/json" \ + -X POST \ + http://localhost:3000/api/boards \ + -d '{"title":"Board title here","owner":"ABCDE12345","permission":"private","color":"nephritis"}' +``` + +## How REST API is implemented in Wekan code wekan/models/boards.js - -Wekan logo \ No newline at end of file +``` + JsonRoutes.add('POST', '/api/boards', function (req, res) { + try { + Authentication.checkUserId(req.userId); + const id = Boards.insert({ + title: req.body.title, + members: [ + { + userId: req.body.owner, + isAdmin: req.body.isAdmin || true, + isActive: req.body.isActive || true, + isNoComments: req.body.isNoComments || false, + isCommentOnly: req.body.isCommentOnly || false, + }, + ], + permission: req.body.permission || 'private', + color: req.body.color || 'belize', + }); +``` \ No newline at end of file