Get all content metadata in json for space

Hello Everyone,

                       I am newbie to confluence rest api and I am trying to pull all content in my space. Below is link I am using:

https://servername/rest/api/content?spaceKey=space1&limit=2000&expand=version 

I believe this will pull all content metadata as json for space1, alongwith version.

This is not giving me everything in json. They is lot of missing metadata for space1, not appearing in json file.

Increasing limit is not making any difference in json content I am getting back.

Could you please help here, if I am doing something wrong?

Thanks in advance.

1 answer

This widget could not be displayed.

Hi,

You need to ask Confluence to expand the response further. The Confluence API uses expandable elements - in your example, you've only expanded version. You can see which elements are expandable by looking at the _expandable element in the response when you do a GET.

It will look something like this:

"_expandable": {
        "container": "/rest/api/space/TEST",
        "metadata": "",
        "operations": "",
        "children": "/rest/api/content/1234/child",
        "history": "/rest/api/content/1234/history",
        "ancestors": "",
        "body": "",
        "version": "",
        "descendants": "/rest/api/content/1234/descendant",
        "space": "/rest/api/space/TEST"
      }

Each of these elements can be expanded further in the payload with the expand parameter on the request. If you're trying to get all content, try starting by expanding "body.storage,version".

From there, if there is still other meta info that you want, examine the result for more expandable markers and add them accordingly until you have all the data you need

Hope this helps!

Thanks Aaron for your response. This absolutely helped me to get more details for any specific title related information.
My issue is related to pages I am getting in result json .

I find out the limit restriction on my confluence. Even I mentioned limit as 2000, it is giving me only 200 back.

How I can increase system limit to a higher value?

Hi,

I apologize for misunderstanding your question; I thought what you meant by "missing metadata" was that information about the page was missing, i.e, the content.

Your use of the limit parameter is correct, but it seems to me that the limit parameter has a ceiling of 200. If you look at the last part of the response:

"start": 0,
  "limit": 200,
  "size": 169,
  "_links": {
    "self": "https://localhost/confluence/rest/api/content?spaceKey=TEST&expand=version",
	"next": "/rest/api/content?spaceKey=TEST&expand=version&limit=5&start=5",
    "base": "https://localhost/confluence",
    "context": "/confluence"
  }

It'll note what the limit is on returned content. It seems that any value >= 200 is capped at 200; anything lower than that will match what you specify. I am not sure if it is possible to increase this maximum limit.

However, what you can do, is write your Java code for parsing in a while loop, that will keep calling the URL designated as next and aggregating the results.

You can do something like the following:

1) Parse the JSON, store results as you deem fit

2) Look for the _links block in the trailer

3) If next is not null, do a GET on the provided URL

4) Repeat until next is null

That way you'll aggregate the results and get everything. It is more service calls but will get you your data.

Hope this helps you!

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Tuesday in Confluence

Add-on evaluation with confluence templates

Atlassian market place contains number of Apps/Addons which improves the capability of out of the box Atlassian products. It is good to follow a plugin evaluation process before install add-ons. So t...

137 views 12 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you