cancel
Showing results for 
Search instead for 
Did you mean: 

Rest API Categories excludes other root Categories

0 Kudos

Rest API Categories excludes other root Categories

Feature request from owenhaynes, posted on GitHub Oct 26, 2015

If you have more then one root category the following endpoint only ever returns one.

Have 2 root categories (default and test root) the following is returned

GET /rest/V1/categories

{"id":2,"parent_id":1,"name":"Default Category","is_active":true,"position":1,"level":1,"product_count":0,"children_data":[{"id":3,"parent_id":2,"name":"Cat 1","is_active":true,"position":1,"level":2,"product_count":0,"children_data":[{"id":4,"parent_id":3,"name":"Cat 1 sub","is_active":true,"position":1,"level":3,"product_count":0,"children_data":[{"id":5,"parent_id":4,"name":"Cat 1 sub sub","is_active":true,"position":1,"level":4,"product_count":1,"children_data":[]}]}]}]}

should this end point not return an array so that all the root categories are listed?

This is very similar to #2096, as I guess he was only using root categories

5 Comments
apiuser
New Member
Status changed to: Investigating
 
apiuser
New Member

Comment from choukalos, posted on GitHub Oct 29, 2015

yes this looks like a bug; you should be able to see the 2nd 'test' root category. Internal ticket MAGETWO-44763

apiuser
New Member

Comment from choukalos, posted on GitHub Nov 04, 2015

Closing 44763; this isn't a bug - you can only have 1 root category per store view. If you create a root category in admin under default it's just a floating category. You should really be creating a root category associated with a store view. Seems we should add a service to assign categories to store view ( APIs auto assigns if you call out a store view ( not default ) in your url ). I'll put that work in our internal epic - MAGETWO-11434

apiuser
New Member

Comment from owenhaynes, posted on GitHub Nov 04, 2015

if that that case could we at least remove the default category from the root of this end point? as it does not flow as categories should return some sort of list? or users will have to filter this when using restangular or similar as it expects a collection at /rest/V1/categories


Restangular.service('categories').getList();
apiuser
New Member

Comment from mackelito, posted on GitHub Mar 17, 2016

Is there any examples using Restangular? If yes I would love to see it! Smiley Happy