Wiki.js is a powerful tool, and I’ve enjoyed using it. The user interface is pretty intuitive, it looks great, and as a developer, I was excited to learn it even has a great API!

Well, mostly.

Problems arise if you ever want to use the API to access an individual page. And it doesn’t help that if you ask about it, the official response is that it’ll be fixed in a version that might come out someday.

I was confused - as the administrator, surely I had permission to look at a page, right? Well, no, as it turns out:

{
  "errors": [
    {
      "message": "You are not authorized to view this page.",
      "locations": [
        {
          "line": 3,
          "column": 5
        }
      ],
      "path": [
        "pages",
        "single"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stack": "PageViewForbidden 6013: You are not authorized to view this page.\n    at single (/opt/wikijs/server/graph/resolvers/page.js:167:17)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)",
          "code": 6013,
          "message": "You are not authorized to view this page.",
          "stacktrace": [
            "PageViewForbidden 6013: You are not authorized to view this page.",
            "    at single (/opt/wikijs/server/graph/resolvers/page.js:167:17)",
            "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
          ]
        }
      }
    }
  ],
  "data": {
    "pages": {
      "single": null
    }
  }
}
  

So, after digging around, I found this comment by GitHub user NellsRelo.

I ran into this as well, but was able to get it working by giving the group Manage Page permissions. This isn’t an ideal solution, as the API key could be then used to move or rename pages, but may shed light on the nature of the bug

– NellsRelo, May 4, 2024

So, it seemed I just had to add the Manage Page permission, right?

… but I couldn’t. I was the administrator. Administrator permissions can’t change.

Admin Permissions

So I just needed to make a new group, Super-Admin, and assign the permissions there, right?

Super Admin Permissions

… Nope. That didn’t work, either. So after pulling out some hair and shouting into the void, I finally got it - the permissions I needed weren’t permissions at all.

They were Rules.

Page Rules

Nothing worked until I had also set the manage:pages Page Rules. I updated that, and everything snapped into place and I was able to use single and singleByPath queries with no problem. And with that, I was finally able to get the preview working for my Wiki.js Command Palette Extension!

Wiki Extension