Magento – API working but doesn’t return any data

apirest

For testing purposes I've setup a REST Guest role with "All" access across the Catalog in my store, so I can throw some queries at the API whilst I find my feet.

Using Simple REST client in Chrome I can issue a GET request to http://www.mystore.co.uk/api/rest/products/1/categories which in theory should return the name of the category(ies) that product ID 1 has assigned to it?

I'm getting a success (200 – OK) response but the only actual data I get returned in Simple REST Client is "[[]]" rather then the name of the category that product ID 1 is in. I've verified that the product definitely has a category assigned.

Any ideas where I'm going wrong?

Thanks.

Best Answer

The request shouldn't give you the name of the category but rather it's id.
The expected resonse should be something like the following JSON (or XML depending on your HTTP request Accept header).

[{"category_id":"3"}]

The empty response you posted indicates that you didn't assign the Catalog > Product > Product Category > Read > Category ID to the REST Guest Role ACL Attributes Information.

You can set those in the adminhtml backend at
System > Web Services > REST - Attributes. Then choose the Guest Role and make the assignment.