cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 API update category not working

SOLVED

Magento 2 API update category not working

Hello,

 

I upload the category with API. This is working:
HTTP POST /V1/categories

Deleting also working

 

But now I want to change an existing with:

 

PUT /rest/V1/categories/72/

72 = id of the category

My JSON:

{
"category": {
"custom_attributes": [{
"attribute_code": "image",
"value": "erpTestCategory3.png"
},
{
"attribute_code": "description",
"value": "Description Test"
}],
"id": 72,
"include_in_menu": true,
"is_active": false,
"name": "erp Test Category-3",
"parent_id": 70
}
}

But nothing happens ... I get HTTP/1.1 200 OK back.

 

But no new name or other is new.

Made I´m something wrong?

 

3 REPLIES

Re: Magento 2 API update category not working

Hi @hanhoe

 

I think you missed something on parameter level - i have tried with call on my postman its and its working 

 

Kindly check below details and do the same , that will work !

 

URL -  http://your URL/index.php/rest/V1/categories/45/

 

Method : PUT

 

Below is the exact json parameters :

 

{  
   "category":{  
      "id":"45",
      "name":"OILFIELD",
      "is_active":"true",
      "include_in_menu":"true",
      "parent_id":"11652",
       "customAttributes":[  
         {  
            "attributeCode":"description",
            "value":"OILFIELDs\n"
         },
         {  
            "attributeCode":" ",
            "value":" "
         },
         {  
            "attributeCode":"is_anchor",
            "value":"1"
         },
         {  
            "attributeCode":"is_feature",
            "value":1
         },
         {  
            "attributeCode":" ",
            "value":" "
         },
         {  
            "attributeCode":" ",
            "value":" "
         }
      ]
   }
}

Try this way and check it will works 

 

 

if issue solved,Click Kudos & Accept as Solution

Re: Magento 2 API update category not working

Hello,

 

no it didn´t work .. but I found the solution. I have to use:

http://your URL/rest/all/V1/categories/45/

 

 

Re: Magento 2 API update category not working

Hi @hanhoe

 

Yes - sometimes we need to pass all keyword in the url - but its also worked without all as well !

 

Anyways glad to know that you have resolved your issue - do answer accept as solution - so other user gets helped on the same 

 

happy to help and keep helping Smiley Happy 

if issue solved,Click Kudos & Accept as Solution