Skip to content

Confluence connector fails with 400 when using space key — v2 API requires numeric space ID #49

Description

@satjak

Confluence connector fails with 400 when using space key — v2 API requires numeric space ID

Summary

The oikb documentation and README show that a Confluence space should be configured using its key:

sources:
  - name: handbook
    source: confluence:ENG

This does not work. Confluence Cloud's v2 API rejects the space key with 400 Bad Request when it appears as a path parameter. The only workaround is to manually look up the numeric space ID and use that instead — which contradicts the documented behavior and is not mentioned anywhere in the docs.


Description

The Confluence connector passes the space key directly to the /wiki/api/v2/spaces/{id}/pages endpoint:

resp = self._http.get(
    f"/api/v2/spaces/{self.space_key}/pages",
    params=params,
)

Confluence Cloud's v2 API only accepts a numeric space ID in that path parameter — not a space key string like ENG or TECH. Passing a key returns 400 Bad Request.

The key format (confluence:ENG) works fine for the /api/v2/spaces?keys=ENG lookup endpoint, but not for /api/v2/spaces/{id}/pages.


Workaround

Look up the numeric ID for your space first:

curl -u "user@company.com:TOKEN" \
  "https://company.atlassian.net/wiki/api/v2/spaces?keys=ENG"

Then use the numeric id from the response in the source config:

source: confluence:9959866368  # numeric ID, not key

Expected Behaviour

confluence:ENG should work as documented. The connector should resolve the space key to a numeric ID via /api/v2/spaces?keys={key} before fetching pages.


Suggested Fix

Add a key→ID resolution step in ConfluenceConnector.__init__ or build_manifest:

resp = self._http.get("/api/v2/spaces", params={"keys": self.space_key})
resp.raise_for_status()
results = resp.json().get("results", [])
if results:
    self.space_key = results[0]["id"]

Environment

  • Confluence Cloud
  • oikb v0.3.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions