I can’t update product categories acf field from REST API
-
I need to update via REST API the WooCommerce product category ACF Fields
From my web site made in Classic ASP, I try to call another web site made in WordPress.I’ve tried with different end points and Posted the json strings (method post POST):
1)
EndPoint: https://myweb/wp-json/wc/v3/products/categories/54 (54 is a Woocommerce category)
Json:
{“id”:”54″,”name”:”MyName modified”,”slug”:”MyName-modified”,”fields”:[{“key”:”title_01″,”value”:”MyTitle”},{“key”:”text_01″,”value”:”MyTextCat”}]}(for woocommerce products, this method works correctly. EndPoint used: https://myweb/wp-json/wc/v3/products)
I tried to use in the json string, the word “fields”, “meta_data”, “acf” and others… but the acf fields do not update! only the category fields were updated (id, name, slug).
2)
EndPoint: https://myweb/wp-json/acf/v3/categories/54
Json:
{“title_01″:”MyTitle”}
or
{“fields”: {“title_01”: “My title”, “text_01”: “My text”}}
or
{“acf”: {“title_01”: “My title”, “text_01”: “My text”}}It not works. It returns the error:
{“code”:”cant_update_item”,”message”:”Cannot update item”,”data”:{“status”:500}}
But… I have de permission to modify woocommerce categories, woocommerce products, woocommerce products acf fields. Only woocommerce category acf field don’t update!!!
I use JWT Autentication and it works correctly.If I make a GET call of the url (https://myweb/wp-json/acf/v3/categories/54), the response is:
{“acf”:{“title_01″:”My title”,”text_01″:”My text”,}}
… so it seems that this end point is not editable: /wp-json/acf/v3/{taxonomy}/{id}I also tried to modify the acf fields of Posts Categories … but i doesn’t work correctly!!
EndPoint: https://myweb/wp-json/wp/v2/categories/57 (57 is a Post Category… not a woocommerce category!… I don’t understand why with the same end-point it returns me woocommerce categories and also posts categories!!)Can you help me?
What is the correct end point… and the correct json string to send by post?
How can I update via REST API the WooCommerce categories ACF fields?My WP version is: 5.3.2
My Advanced Custom Fields PRO version is 5.8.8Pablo Benenati
- The topic ‘I can’t update product categories acf field from REST API’ is closed to new replies.