The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do i use the Confluence v2 REST api to create labels on new or existing pages?

Mark McCurdy
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 6, 2024

I'm simply trying to add a label to a new page via v2 REST api. The documentation shows no v2 API that POSTs labels. All are read-only. The v1 api doesn't say deprecated for /content/{id}/label, but here lies the problem.

v1 references pages as "content" while v2 has almost entirely dropped the use of "content." ContentID does not equal PageID. My test consisted of using the page ID to fetch the content ID and then performing the v1 api label POST against the contentID. This gave me a 403 forbidden despite having full access.

Build new page. Use its pageID to get contentID
confluence_rest_api_url + "/wiki/api/v2/pages/ + str(pageid) + "/properties"
The result is in field "id"

confluence_rest_api_url + "/wiki/rest/api/content/str(contentid)/label
The POST body has the label structure: array of objects

403 error.

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Deleted user
June 6, 2024

Hello @Mark McCurdy 

I'm simply trying to add a label to a new page via v2 REST API

The simple answer is... you can't. The v2 API endpoints are under development and many of the v1 capabilities are yet to be replicated, so you need to keep using the appropriate v1 endpoints in the interim.

Refer to this thread where the same question has previously been asked, or refer to CONFCLOUD-76866 for the corresponding feature request.

As for the reason behind the great schism between v1 referring to Content generically versus v2 referring to Pages specifically, the recording of the Updates to Confluence REST API v2 presentation from Atlas Camp last year is an excellent explanation of why it's being done.

You can find all this type of information for yourself by using Google. You should try it sometime.

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events