Order of content children in REST API response
Asked by Steve Jorgensen:

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?


Answers:
author: Jessica
body: 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](https://developer.atlassian.com/cloud/confluence/rest/api-group-content---children-and-descendants/#api-wiki-rest-api-content-id-child-get) 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](https://developer.atlassian.com/cloud/confluence/rest/api-group-content---children-and-descendants/#api-wiki-rest-api-content-id-child-type-get)

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

Cheers,  
Jessica

comments: author: Steve Jorgensen
body: 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.


author: Steve Jorgensen
body: See also <https://community.atlassian.com/t5/Confluence-Cloud-questions/REST-API-order-of-items-in-ancestors-for-various-object-types/qaq-p/2053796#M5284>


author: Jessica
body: 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.

<br />

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


author: Steve Jorgensen
body: Thanks very much. :)


Tags: cloud

confluence-cloud

rest-api