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

Order of content children in REST API response

Steve Jorgensen June 13, 2022

Experimentally, I am finding that the order of the items in the response to a `GET /wiki/rest/api/content/{id}/child` API call is the same as the order in which they appear in the WEB UI.

The API documentation does not actually say anything about the order though, so I am nervous about relying on that.

If the order cannot be relied upon, I see that there is a `position` extension in the results that seems to represent the display order, but that is not mentioned in the API documentation, so I don't know if I can rely on its meaning or continued existence.

Can all of this be clarified in the documentation?

1 answer

0 votes
Jessica
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 21, 2022

Hi Steve,

I'm not sure if I got your question right, so I'd like to ask for more details on what exactly is this position and display order of results you mentioned and what are you looking to clarify.
Would be the ones under for example:

  • https://<sitename>.atlassian.net/wiki/rest/api/content/<pageID>/child?/comment

And what is shown under the expandable, such as body, for example?

The link to the documentation along with additional information for your use case would be useful for us to understand your concern a little better. :) 

Assuming that you are trying to follow the REST API Get content children with the provided path:

  • /wiki/rest/api/content/{id}/child or https://<sitename>.atlassian.net/wiki/rest/api/content/<pageID>/child, you should see the expandable options that you can explore, which are the content type of the pageid used:
    E.g: https://<sitename>.atlassian.net/wiki/rest/api/content/<pageID>/child/comment
  • page: child content is page, comment, attachment
  • blogpost: child content is comment, attachment
  • attachment: child content is comment
  • comment: child content is attachment

So, in order to retrieve for example, all comments in the specified page, you could use the following:

https://<sitename>.atlassian.net/wiki/rest/api/content/<pageID>/child/comment?expand=body.view

For reference, all other expendables are listed here: Get content children by type 

Hope that helps, but in case you concern is a bit different, please let us know.

Cheers,
Jessica

Steve Jorgensen June 22, 2022

Thanks for replying.

No. That's not exactly what I'm asking.

In this case, I am actually getting child pages of a page (so https://<sitename>.atlassian.net/wiki/rest/api/content/<pageID>/child/page) and I'm talking about the order in which the child pages appear in the content array in the response data.

I need to know the order that the child pages appear when viewed through the Web UI. Experimentally, it seems that the items in the content array are the same as the order in which they appear in the Web UI, and each item in the response also contains an `extensions.position` value (not an expandable) with values that are in ascending order (though not sequential) corresponding with the position.

Neither the order if entries in the response nor the meaning of that extension appear to be mentioned in the documentation, so I don't know whether I can rely on either of those.

Jessica
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 5, 2022

Thank you for the clarification and my apologies for the delay getting back to you, Steve!

I got it wrong at first, but after some tests here, I can confirm to you that all results switching pages in the hierarchy in UI, reflected in the API indeed, like in your tests shared in the other thread.


Although it is not sequential, the lower the number in the position is, result, higher the page is in the hierarchy under that specific parent page.
Moving the pages in the UI, confirmed that as well.

Regarding the documentation, we indeed do not have it covered in the our REST API documentation.

Thank you for bringing it to our attention! I have contacted our developers about this information not being there and we will be reviewing internally together, to see if this is possible to be added to our official documentation.

Hope this helps with your question!
Jessica

Like Steve Jorgensen likes this
Steve Jorgensen July 5, 2022

Thanks very much. :)

Like Jessica likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events