5

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.

1 Answer 1

5

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.

1
  • Fixed my problem immediately, thanks @Vinai. There are so many configuration options in M1 that it's hard to work out what's causing something like this. Commented Dec 17, 2020 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.