Using Kentico REST API to get document and related categories

Virgil Carroll asked on December 18, 2016 18:38

Anyone know a way to pull back all documents of a certain class (already have this part working) but also pull in the Kentico Categories that have been set in the Categories tab under properties?

Not sure if the Kentico API supports chained paths or not...but not seeing anything about it

Recent Answers


Anton Grekhovodov answered on December 18, 2016 19:24

Hi Virgil,

There is an example how to get document categories in Kentico 8. I think it's the same for K9: Example - Displaying categories in document lists. So you just need to use CategoryInfoProvider.GetDocumentCategories method to get document categories.

Also, there is an API example for Kentico 9. You can see that there are CategoryInfoProvider and DocumentCategoryInfoProvider. The first works with CategoryInfo objects which describe Category entity, the second one works with DocumentCategoryInfo objects which describe a relation between category and document (pages)

0 votesVote for this answer Mark as a Correct answer

Virgil Carroll answered on December 19, 2016 02:15

Anton,

Where I appreciate your answer, this was not what I was asking, as I do know those methods :) What I was asking is through a Restful API call (i.e.

0 votesVote for this answer Mark as a Correct answer

Anton Grekhovodov answered on December 19, 2016 05:31

Hi Virgil,

Ok, I'm not good in English, maybe that's why I didn't understand you correctly) You can use /cms.category resource path to get categories. Then you can get all bingings between a page and categories /cms.menuitem/53/bindings/cms.documentcategory or get all bindings for all pages /cms.documentcategory and then merge these entities.

2 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on December 19, 2016 08:45

Virgil, Kentico Rest API is not very good when you work with complex objects (e.g. user and user settings), so it might be easier to inplement custom web api controller that will return structure you need vs. making a couple of requests from client and merging data there.

However if you want to stay with REST API approach, anton described should work.

0 votesVote for this answer Mark as a Correct answer

Virgil Carroll answered on December 19, 2016 14:06

Thanks Anton, I appreciate the additional response (and Roman) this was for a simple need that I did not want to put a lot of work into (something internal), so I will take a look at the bindings functionality.

Do either of you, or anyone else, know if there is better documentation out there around the Kentico REST API than just what is in the Kentico documentation? It seems seriously lacking if the API can do more stuff.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on December 19, 2016 16:18

Unfortunately I'm not aware of any better resource.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.