Skip to content

Confluence Cloud: add and delete labels through the v1 endpoint - #1693

Open
R3gardless wants to merge 2 commits into
atlassian-api:masterfrom
R3gardless:fix/confluence-cloud-label-write-v1
Open

R3gardless wants to merge 2 commits into
atlassian-api:masterfrom
R3gardless:fix/confluence-cloud-label-write-v1

Conversation

@R3gardless

Copy link
Copy Markdown

Problem

ConfluenceCloud.add_page_label(), add_page_labels() and delete_page_label() send POST / DELETE to api/v2/pages/{id}/labels.

The Confluence Cloud v2 API only defines GET for every label path. From Atlassian's own v2 OpenAPI spec (https://dac-static.atlassian.com/cloud/confluence/openapi-v2.v3.json, info.version 2.0.0):

/attachments/{id}/labels        ['GET']
/blogposts/{id}/labels          ['GET']
/custom-content/{id}/labels     ['GET']
/labels                         ['GET']
/labels/{id}/attachments        ['GET']
/labels/{id}/blogposts          ['GET']
/labels/{id}/pages              ['GET']
/pages/{id}/labels              ['GET']
/spaces/{id}/labels             ['GET']
/spaces/{id}/content/labels     ['GET']

There is no label write endpoint in v2 at all, so these three methods cannot work against Cloud today.

Change

  • Add a page_labels_write entry to ConfluenceEndpoints.V2 pointing at the v1 path rest/api/content/{id}/label, which is still served on Cloud.
  • Use it in add_page_label(), add_page_labels() and delete_page_label(), and send the payload shape v1 expects: [{"prefix": "global", "name": "<label>"}].
  • Reading labels (get_page_labels(), get_space_labels()) is unchanged and stays on v2.
  • Docstrings now say the write goes through v1 and that the response is the v1 payload (labels in results).

Tests

  • tests/test_confluence_v2.py: test_add_page_label, test_add_page_labels, test_delete_page_label now assert the v1 endpoint and payload.
  • tests/test_confluence_v2_with_mocks.py: test_add_page_label mocks the v1 endpoint.
  • Full suite: 1751 passed, 10 skipped.

The Confluence Cloud v2 API only defines GET for /pages/{id}/labels, so
add_page_label(), add_page_labels() and delete_page_label() were sending
POST/DELETE to an endpoint that does not accept them.

Route those three writes to the v1 endpoint rest/api/content/{id}/label,
which is still available on Cloud, and send the payload shape it expects
([{"prefix": "global", "name": ...}]). Reading labels stays on v2.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant