Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to find a page with given label name using confluence REST API

Oleg Vrublevsky December 12, 2014
I found example of how to find a page by title.
Is it possible to do the same for label like "mylabel"? 

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Steven F Behnke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2014

Well, welcome to the ecosystem and atlassian answers Oleg. Hello and how are you?

Anyway, to answer your questions and more than you even asked: The Confluence REST API itself and Confluence Query Language are currently under development. Soon you should be able to query for things like labels via a stable API path but currently as you noticed, yes those are published under the path Experimentalyellow which means they are subject to change at some point.  Atlassian hasn't quite laid out the timeline on completion of this project but I can give you a few pointers on resources I suppose. 

If you're interested in learning more about these concepts and where they are at the moment, I suggest you check out these documents:

Reference Documents

Confluence Developer

Atlassian Project Tracking

Steven F Behnke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 12, 2014
Oleg Vrublevsky December 15, 2014

Thank you!

0 votes
Bruce Coveny March 20, 2015

As @Steven Behnke metioned the documentation to Advanced searching with CQL.  This may be what you are looking for and is not supported until version 5.7.  This helped me accomplish something similar.

http://servername/rest/api/content/search?cql=type=page%20AND%20label=playground

 

0 votes
Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2014

I don't know of a great way to do it with the REST API yet. But here is how I am doing it in our instance.

<script type="text/javascript">
AJS.$.ajax({
    dataType: 'json',
    contentType: 'application/json',
    type: 'POST',
    url: '/rpc/json-rpc/confluenceservice-v2/getLabelContentByName',
    data: '["{your label here}"]', //<-- change this
    success: function(data){
        for(var dat in data) {
            //Do stuff here
        }
    }
});
</script>
Oleg Vrublevsky December 15, 2014

Thank you for solution, though they say RPC APIs are going to be deprecated after 5.5: https://developer.atlassian.com/display/CONFDEV/Confluence+REST+API

Oleg Vrublevsky December 15, 2014

It seems I have two options here: either go with deprecated or with experimental API :) building a plugin to provide REST API extension, unfortunately, is not an option in my case due to possible deployment limitations.

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 16, 2014

The deprecation simply means that they are not adding features to that API right now as they are going to focus on the REST API. However, it cannot go away for a while as there is much functionality in the old APIs that is not in REST yet.

0 votes
Oleg Vrublevsky December 12, 2014

Is "experimental" API the only way? Guys, today is my first day as "confluence developer" and I'm probably starting with the most "stupid" questions, but, is "experimental" API stable enough for using it in production?

btw, here is what solves my problem:

/rest/experimental/content/?expand=body.storage%2Cversion%2Cancestors%2Cmetadata.labels%2Clabels&cql=label=mylabel

 

Thanks!

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events