0

As the title says, I want to modify the value of a custom attribute of each of my categories in magento 2.4 and I want to do this using REST APIs.

I am using this endpoint https://magento.redoc.ly/2.4.0-admin/tag/categoriesid#operation/catalogCategoryRepositoryV1SavePut What I do not understand is that endpoint works fine if I want to modify the name of the category, but it does not work for the custom attributes. The changes are not saved.

I send the put request and the old data is returned with the incorrect/old custom attr value.

This is what I am doing:

response = requests.put("/rest/V1/categories/1111",
                        data=json.dumps({
                            "category":
                                {
                                    "id": 1111,
                                    "parent_id": 1000,
                                    "name": "cat name",
                                    "is_active": True,
                                    "position": 1,
                                    "level": 4,
                                    "path": "1/2/1031/6000/6001",
                                    "include_in_menu": True,
                                    "custom_attributes": [
                                        {
                                            "attribute_code": "description",
                                            "value": "new_value"
                                        }
                                    ]
                                }
                        }),
                        headers={
                            "Content-Type": "application/json",
                            "Authorization": "Bearer {}".format(token)
                        }, timeout=config.timeout)

I should see new_value as the value of the attr description, but I see value which is the old value.

Anyone has any ideas what I am doing wrong? Should I use another endpoint?

Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.