Can’t update product using REST API
-
I have the same problem with this closed ticket:
https://www.ads-software.com/support/topic/woocommerce-rest-api-update-product/“After the PUT to update the product, I receive back the product JSON, without any error, but it comes back with the old price. the same happens for other attributes of the product.”
unfortunately, Ultimate Peter’s answer can’t resolve the problem.
I already tried to use JSON encoding and Text encoding, but the result is always the same.
anybody has an insight about this?
thanks before
The page I need help with: [log in to see the link]
-
I forgot to mention, when I try using curl to call woocommerce /wp-json/wc/v3/products/32 from my mac’s terminal, it’ll return 301 permanently moved page.
this is my curl script:
curl -X PUT https://domain_name/wp-json/wc/v3/products/32 \
-u ck_2b6c661ac5764d71f63c4ba60a4475bd6ebef7c6:cs_a09f45e6bfd74306ed6ec15be9f82cb59b01d95a\
-H “Content-Type: application/json” \
-d ‘{
“stock_quantity”: 21
}’`Hi @barotoardi,
I can’t replicate the issue you reported with the REST API. I’m sending this PUT request to update the stock quantity of my “Hoodie” product with actual stock (10) and it works. The stock increases to 11 after sending the request in Postman.
curl -X PUT https://mywebsite.com/wp-json/wc/v3/products/44 \
-u ck_7bca6231224b0c6ae9c19775df1021ac85u9ac16:cs_c721f36813fc36djh65b73001a81ba831f045b94 \
-H “Content-Type: application/json” \
-d ‘{
“stock_quantity”: “11”
}’Can you try removing
https://
and leaving it with only the domain name? Also, instead of“stock_quantity”: 21
change it to“stock_quantity”: "21"
. Let’s see if it works.If not, send us a screenshot of the error message and your system status (you can redact the website URL). You can find it via WooCommerce > Status. Select “Get system report” and then “Copy for support”. Once you’ve done that, paste it here in your response.
Cheers.
Hi, tried without https:// still response product data but not updated.
Here is system report:
### WordPress Environment ###WordPress address (URL): https://www.*********
Site address (URL): https://www.*********
WC Version: 6.5.1
REST API Version: ? 6.5.1
WC Blocks Version: ? 7.4.3
Action Scheduler Version: ? 3.4.0
Log Directory Writable: ?
WP Version: 6.0
WP Multisite: –
WP Memory Limit: 512 MB
WP Debug Mode: –
WP Cron: ?
Language: en_US
External object cache: –### Server Environment ###
Server Info: LiteSpeed
PHP Version: 7.4.29
PHP Post Max Size: 50 MB
PHP Time Limit: 300
PHP Max Input Vars: 1000
cURL Version: 7.29.0
NSS/3.53.1SUHOSIN Installed: –
MySQL Version: 5.5.5-10.3.27-MariaDB-cll-lve
Max Upload Size: 50 MB
Default Timezone is UTC: ?
fsockopen/cURL: ?
SoapClient: ?
DOMDocument: ?
GZip: ?
Multibyte String: ?
Remote Post: ?
Remote Get: ?### Database ###
WC Database Version: 6.5.1
WC Database Prefix: qrtavad8r_
Total Database Size: 27.47MB
Database Data Size: 23.94MB
Database Index Size: 3.53MB
qrtavad8r_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
qrtavad8r_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
qrtavad8r_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
cerber_acl: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
cerber_blocks: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
cerber_countries: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
cerber_lab: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
cerber_lab_ip: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
cerber_lab_net: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
cerber_log: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
cerber_qmem: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
cerber_traffic: Data: 1.52MB + Index: 0.05MB + Engine InnoDB
qrtavad8r_actionscheduler_actions: Data: 0.06MB + Index: 0.13MB + Engine InnoDB
qrtavad8r_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_actionscheduler_logs: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_cerber_files: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_cerber_sets: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_cerber_uss: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
qrtavad8r_duplicator_packages: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_itsec_bans: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_itsec_dashboard_events: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_itsec_distributed_storage: Data: 7.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_itsec_fingerprints: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_itsec_geolocation_cache: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_itsec_lockouts: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
qrtavad8r_itsec_logs: Data: 3.50MB + Index: 0.11MB + Engine InnoDB
qrtavad8r_itsec_mutexes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_itsec_opaque_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_itsec_temp: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
qrtavad8r_itsec_user_groups: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_litespeed_url: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_litespeed_url_file: Data: 0.02MB + Index: 0.08MB + Engine InnoDB
qrtavad8r_masterslider_options: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_masterslider_sliders: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_newsletter: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_newsletter_emails: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_newsletter_sent: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_newsletter_stats: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_newsletter_user_logs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_options: Data: 5.47MB + Index: 0.09MB + Engine InnoDB
qrtavad8r_postmeta: Data: 1.52MB + Index: 0.55MB + Engine InnoDB
qrtavad8r_posts: Data: 1.50MB + Index: 0.22MB + Engine InnoDB
qrtavad8r_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_term_relationships: Data: 0.06MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_usermeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
qrtavad8r_wc_admin_notes: Data: 0.06MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
qrtavad8r_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
qrtavad8r_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_wc_product_meta_lookup: Data: 0.05MB + Index: 0.09MB + Engine InnoDB
qrtavad8r_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_wt_iew_action_history: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_wt_iew_cron: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_wt_iew_ftp: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_wt_iew_mapping_template: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
qrtavad8r_yoast_indexable: Data: 1.52MB + Index: 0.33MB + Engine InnoDB
qrtavad8r_yoast_indexable_hierarchy: Data: 0.08MB + Index: 0.05MB + Engine InnoDB
qrtavad8r_yoast_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
qrtavad8r_yoast_primary_term: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
qrtavad8r_yoast_seo_links: Data: 0.02MB + Index: 0.03MB + Engine InnoDB### Post Type Counts ###
attachment: 533
elementor_library: 1
itsec-dash-card: 6
itsec-dashboard: 1
ml-slide: 4
ml-slider: 1
nav_menu_item: 43
page: 13
post: 2
product: 174
revision: 109
shop_order: 3### Security ###
Secure connection (HTTPS): ?
Hide errors from visitors: ?### Active Plugins (19) ###
iThemes Security: by iThemes – 8.1.2
Branda: by WPMU DEV – 3.4.7
Classic Editor: by WordPress Contributors – 1.6.2
Easy WP SMTP: by wpecommerce
alexanderfoxc – 1.4.7Site Kit by Google: by Google – 1.75.0
LiteSpeed Cache: by LiteSpeed Technologies – 4.6
Master Slider: by averta – 3.8.1
Midtrans – WooCommerce Payment Gateway: by Midtrans – 2.32.1
Newsletter: by Stefano Lissa & The Newsletter Team – 7.4.6
Payment Reminder: by Tonjoo Studio – 2.0.3
Plugin Konfirmasi Pembayaran: by Tonjoo Studio – 2.0.2
Plugin Ongkos Kirim: by Tonjoo Studio – 3.8.6
Plugin Refund: by Tonjoo Studio – 2.0.0
Plugin Resi: by Tonjoo Studio – 1.2.6
Storefront Add Slider: by Atlantis Themes – 0.4
Taxonomy Images: by Michael Fields
Ben Huson – 1.0WooCommerce: by Automattic – 6.5.1
Yoast SEO: by Team Yoast – 18.9
WP Cerber Security, Anti-spam & Malware Scan: by Cerber Tech Inc. – 9.0### Inactive Plugins (6) ###
Duplicator: by Snap Creek – 1.4.6
Email Test: by SiteAlert – 1.0.2
Max Mega Menu: by megamenu.com – 2.9.6
MetaSlider: by MetaSlider – 3.27.5
Regenerate Thumbnails: by Alex Mills (Viper007Bond) – 3.1.5
UpdraftPlus – Backup/Restore: by UpdraftPlus.Com
DavidAnderson – 1.22.12### Dropin Plugins (1) ###
maintenance.php: maintenance.php
### Settings ###
API Enabled: ?
Force SSL: –
Currency: IDR (Rp)
Currency Position: left_space
Thousand Separator: .
Decimal Separator: ,
Number of Decimals: 0
Taxonomies: Product Types: external (external)
grouped (grouped)
simple (simple)
variable (variable)Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)Connected to WooCommerce.com: –
Enforce Approved Product Download Directories: –### WC Pages ###
Shop base: #15 – /shop/
Cart: #16 – /cart/
Checkout: #17 – /checkout/
My account: #18 – /account/
Terms and conditions: ? Page not set### Theme ###
Name: ********* *********
Version: 1.0.0
Author URL: https://childtheme-generator.com/
Child Theme: ?
Parent Theme Name: Storefront
Parent Theme Version: 4.1.0
Parent Theme Author URL: https://woocommerce.com/
WooCommerce Support: ?### Templates ###
Overrides: *********-*********/woocommerce/archive-product.php
### Action Scheduler ###
Complete: 82
Oldest: 2022-05-09 14:05:55 +0700
Newest: 2022-06-07 15:32:56 +0700### Status report information ###
Generated at: 2022-06-08 15:31:47 +07:00
`Hi @barotoardi
Thank you for the System Status.
API requests sometimes get cut off by security plugins or firewalls enabled on the server. Looking at your system status it stood out that you have two active security plugins:
- iThemes Security: by iThemes – 8.1.2
- WP Cerber Security, Anti-spam & Malware Scan: by Cerber Tech Inc. – 9.0
Can you please temporarily deactivate these plugins and check if the API works as expected?
Let us know how it goes.
Ok, I tried to deactivate security plugins. Please find the updated status report:
### WordPress Environment ### WordPress address (URL): https://www.********.id Site address (URL): https://www.********.id WC Version: 6.5.1 REST API Version: ? 6.5.1 WC Blocks Version: ? 7.4.3 Action Scheduler Version: ? 3.4.0 Log Directory Writable: ? WP Version: 6.0 WP Multisite: – WP Memory Limit: 512 MB WP Debug Mode: – WP Cron: ? Language: en_US External object cache: – ### Server Environment ### Server Info: LiteSpeed PHP Version: 7.4.29 PHP Post Max Size: 50 MB PHP Time Limit: 300 PHP Max Input Vars: 1000 cURL Version: 7.29.0 NSS/3.53.1 SUHOSIN Installed: – MySQL Version: 5.5.5-10.3.27-MariaDB-cll-lve Max Upload Size: 50 MB Default Timezone is UTC: ? fsockopen/cURL: ? SoapClient: ? DOMDocument: ? GZip: ? Multibyte String: ? Remote Post: ? Remote Get: ? ### Database ### WC Database Version: 6.5.1 WC Database Prefix: qrtavad8r_ Total Database Size: 27.50MB Database Data Size: 23.97MB Database Index Size: 3.53MB qrtavad8r_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB qrtavad8r_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB qrtavad8r_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB cerber_acl: Data: 0.02MB + Index: 0.02MB + Engine InnoDB cerber_blocks: Data: 0.02MB + Index: 0.00MB + Engine InnoDB cerber_countries: Data: 0.02MB + Index: 0.00MB + Engine InnoDB cerber_lab: Data: 0.02MB + Index: 0.00MB + Engine InnoDB cerber_lab_ip: Data: 0.02MB + Index: 0.00MB + Engine InnoDB cerber_lab_net: Data: 0.02MB + Index: 0.02MB + Engine InnoDB cerber_log: Data: 0.02MB + Index: 0.05MB + Engine InnoDB cerber_qmem: Data: 0.02MB + Index: 0.02MB + Engine InnoDB cerber_traffic: Data: 1.52MB + Index: 0.05MB + Engine InnoDB qrtavad8r_actionscheduler_actions: Data: 0.06MB + Index: 0.13MB + Engine InnoDB qrtavad8r_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_actionscheduler_logs: Data: 0.05MB + Index: 0.03MB + Engine InnoDB qrtavad8r_cerber_files: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_cerber_sets: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_cerber_uss: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB qrtavad8r_duplicator_packages: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_itsec_bans: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_itsec_dashboard_events: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_itsec_distributed_storage: Data: 7.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_itsec_fingerprints: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_itsec_geolocation_cache: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_itsec_lockouts: Data: 0.02MB + Index: 0.08MB + Engine InnoDB qrtavad8r_itsec_logs: Data: 3.50MB + Index: 0.11MB + Engine InnoDB qrtavad8r_itsec_mutexes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_itsec_opaque_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_itsec_temp: Data: 0.02MB + Index: 0.06MB + Engine InnoDB qrtavad8r_itsec_user_groups: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_litespeed_url: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_litespeed_url_file: Data: 0.02MB + Index: 0.08MB + Engine InnoDB qrtavad8r_masterslider_options: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_masterslider_sliders: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_newsletter: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_newsletter_emails: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_newsletter_sent: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_newsletter_stats: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_newsletter_user_logs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_options: Data: 5.47MB + Index: 0.09MB + Engine InnoDB qrtavad8r_postmeta: Data: 1.52MB + Index: 0.55MB + Engine InnoDB qrtavad8r_posts: Data: 1.50MB + Index: 0.22MB + Engine InnoDB qrtavad8r_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_term_relationships: Data: 0.06MB + Index: 0.02MB + Engine InnoDB qrtavad8r_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_usermeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB qrtavad8r_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB qrtavad8r_wc_admin_notes: Data: 0.06MB + Index: 0.00MB + Engine InnoDB qrtavad8r_wc_admin_note_actions: Data: 0.05MB + Index: 0.02MB + Engine InnoDB qrtavad8r_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB qrtavad8r_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB qrtavad8r_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_wc_product_meta_lookup: Data: 0.05MB + Index: 0.09MB + Engine InnoDB qrtavad8r_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_wt_iew_action_history: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_wt_iew_cron: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_wt_iew_ftp: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_wt_iew_mapping_template: Data: 0.02MB + Index: 0.00MB + Engine InnoDB qrtavad8r_yoast_indexable: Data: 1.52MB + Index: 0.33MB + Engine InnoDB qrtavad8r_yoast_indexable_hierarchy: Data: 0.08MB + Index: 0.05MB + Engine InnoDB qrtavad8r_yoast_migrations: Data: 0.02MB + Index: 0.02MB + Engine InnoDB qrtavad8r_yoast_primary_term: Data: 0.02MB + Index: 0.03MB + Engine InnoDB qrtavad8r_yoast_seo_links: Data: 0.02MB + Index: 0.03MB + Engine InnoDB ### Post Type Counts ### attachment: 533 elementor_library: 1 itsec-dash-card: 6 itsec-dashboard: 1 ml-slide: 4 ml-slider: 1 nav_menu_item: 43 page: 13 post: 2 product: 174 revision: 110 shop_order: 3 ### Security ### Secure connection (HTTPS): ? Hide errors from visitors: ? ### Active Plugins (17) ### Branda: by WPMU DEV – 3.4.7 Classic Editor: by WordPress Contributors – 1.6.2 Easy WP SMTP: by wpecommerce alexanderfoxc – 1.4.7 Site Kit by Google: by Google – 1.75.0 LiteSpeed Cache: by LiteSpeed Technologies – 4.6 Master Slider: by averta – 3.8.1 Midtrans - WooCommerce Payment Gateway: by Midtrans – 2.32.1 Newsletter: by Stefano Lissa & The Newsletter Team – 7.4.6 Payment Reminder: by Tonjoo Studio – 2.0.3 Plugin Konfirmasi Pembayaran: by Tonjoo Studio – 2.0.2 Plugin Ongkos Kirim: by Tonjoo Studio – 3.8.6 Plugin Refund: by Tonjoo Studio – 2.0.0 Plugin Resi: by Tonjoo Studio – 1.2.6 Storefront Add Slider: by Atlantis Themes – 0.4 Taxonomy Images: by Michael Fields Ben Huson – 1.0 WooCommerce: by Automattic – 6.5.1 Yoast SEO: by Team Yoast – 19.0 ### Inactive Plugins (8) ### Duplicator: by Snap Creek – 1.4.6 Email Test: by SiteAlert – 1.0.2 iThemes Security: by iThemes – 8.1.2 Max Mega Menu: by megamenu.com – 2.9.6 MetaSlider: by MetaSlider – 3.27.5 Regenerate Thumbnails: by Alex Mills (Viper007Bond) – 3.1.5 UpdraftPlus - Backup/Restore: by UpdraftPlus.Com DavidAnderson – 1.22.12 WP Cerber Security, Anti-spam & Malware Scan: by Cerber Tech Inc. – 9.0 ### Dropin Plugins (1) ### maintenance.php: maintenance.php ### Settings ### API Enabled: ? Force SSL: – Currency: IDR (Rp) Currency Position: left_space Thousand Separator: . Decimal Separator: , Number of Decimals: 0 Taxonomies: Product Types: external (external) grouped (grouped) simple (simple) variable (variable) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) Connected to WooCommerce.com: – Enforce Approved Product Download Directories: – ### WC Pages ### Shop base: #15 - /shop/ Cart: #16 - /cart/ Checkout: #17 - /checkout/ My account: #18 - /account/ Terms and conditions: ? Page not set ### Theme ### Name: ********* ********* Version: 1.0.0 Author URL: https://childtheme-generator.com/ Child Theme: ? Parent Theme Name: Storefront Parent Theme Version: 4.1.0 Parent Theme Author URL: https://woocommerce.com/ WooCommerce Support: ? ### Templates ### Overrides: *********-*********/woocommerce/archive-product.php ### Action Scheduler ### Complete: 83 Oldest: 2022-05-09 14:05:55 +0700 Newest: 2022-06-09 09:54:48 +0700 ### Status report information ### Generated at: 2022-06-09 09:55:14 +07:00
But still can’t update the stock from REST API: /wp-json/wc/v3/products/<<product_id>>
-
This reply was modified 2 years, 8 months ago by
barotoardi.
-
This reply was modified 2 years, 8 months ago by
barotoardi.
Hello,
Thanks for writing back!
Is the issue happening with all products? If it’s related to variable products, please check this topic: https://www.ads-software.com/support/topic/put-api-rest/#post-13469617
yes, it’s happening with all product. All of them are simple products.
Any clue?
Hello @barotoardi ,
I understand this is a difficult situation. Since we are unable to reproduce the error, you can try these:
– Deactivate all plugins except WooCommerce and send the same REST API requests. Check if the prices are getting updated. You can check our conflict test guideline.
– Hosting providers also put some security measures that can block REST API requests. Please contact your host to look for logs & confirm if they are blocking any PUT requests.Let us know what you find.
Thank you.
I tried to create new Woocommerce installation in the same server but only using Woocommerce plugin. Here is the status report:
### WordPress Environment ###WordPress address (URL): https://www.******************.id/test
Site address (URL): https://www.******************.id/test
WC Version: 6.5.1
REST API Version: ? 6.5.1
WC Blocks Version: ? 7.4.3
Action Scheduler Version: ? 3.4.0
Log Directory Writable: ?
WP Version: 6.0
WP Multisite: –
WP Memory Limit: 512 MB
WP Debug Mode: –
WP Cron: ?
Language: en_US
External object cache: –### Server Environment ###
Server Info: LiteSpeed
PHP Version: 7.4.29
PHP Post Max Size: 50 MB
PHP Time Limit: 300
PHP Max Input Vars: 1000
cURL Version: 7.29.0
NSS/3.53.1SUHOSIN Installed: –
MySQL Version: 5.5.5-10.3.27-MariaDB-cll-lve
Max Upload Size: 50 MB
Default Timezone is UTC: ?
fsockopen/cURL: ?
SoapClient: ?
DOMDocument: ?
GZip: ?
Multibyte String: ?
Remote Post: ?
Remote Get: ?### Database ###
WC Database Version: 6.5.1
WC Database Prefix: z8xm4n_
Total Database Size: 4.84MB
Database Data Size: 3.37MB
Database Index Size: 1.47MB
z8xm4n_woocommerce_sessions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
z8xm4n_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
z8xm4n_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
z8xm4n_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
z8xm4n_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_actionscheduler_actions: Data: 0.02MB + Index: 0.11MB + Engine InnoDB
z8xm4n_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_actionscheduler_logs: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
z8xm4n_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_options: Data: 2.44MB + Index: 0.06MB + Engine InnoDB
z8xm4n_postmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_posts: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
z8xm4n_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
z8xm4n_wc_admin_notes: Data: 0.05MB + Index: 0.00MB + Engine InnoDB
z8xm4n_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
z8xm4n_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB
z8xm4n_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB
z8xm4n_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB
z8xm4n_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB
z8xm4n_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB
z8xm4n_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB
z8xm4n_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB### Post Type Counts ###
attachment: 1
page: 7
post: 1
product: 1### Security ###
Secure connection (HTTPS): ?
Hide errors from visitors: ?### Active Plugins (1) ###
WooCommerce: by Automattic – 6.5.1
### Inactive Plugins (1) ###
Akismet Anti-Spam: by Automattic – 4.2.4
### Settings ###
API Enabled: ?
Force SSL: –
Currency: IDR (Rp)
Currency Position: left
Thousand Separator: .
Decimal Separator: ,
Number of Decimals: 0
Taxonomies: Product Types: external (external)
grouped (grouped)
simple (simple)
variable (variable)Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)Connected to WooCommerce.com: –
Enforce Approved Product Download Directories: ?### WC Pages ###
Shop base: #7 – /shop/
Cart: #8 – /cart/
Checkout: #9 – /checkout/
My account: #10 – /my-account/
Terms and conditions: ? Page not set### Theme ###
Name: Storefront
Version: 4.1.0
Author URL: https://woocommerce.com/
Child Theme: ? – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme
WooCommerce Support: ?### Templates ###
Overrides: –
### Action Scheduler ###
Complete: 6
Oldest: 2022-06-09 14:11:04 +0000
Newest: 2022-06-09 14:22:33 +0000### Status report information ###
Generated at: 2022-06-09 14:26:48 +00:00
Same thing happen, when I call endpoint PUT https://domain_name/web_dir/wp-json/wc/v3/products/<<product_id>> it’ll return JSON data of the product.
But now I’m turning off Automatically follow redirects on my Postman and also turn off Permanent SEO-safe 301 redirect from HTTP to HTTPS in my Plesk’s hosting settings.
It turns out when I call the same endpoint, it’ll return 301 Moved Permanently.I tried other things like calling endpoint GET /wp-json/wc/v3/products/<<product_id>>, it will return:
{“code”:”woocommerce_rest_cannot_view”,”message”:”Sorry, you cannot list resources.”,”data”:{“status”:401}}’`
I tried using HTTP Auth Basic and also tried OAuth 1.0 with no success.
I also add this code in my .htaccess:
<IfModule mod_fcgid.c> RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] </IfModule>
What will it suggest any direction for debugging this problem?
It seems that something in my server’s setting make this problem…notes:
there is error but I don’t think it relevant with the problem:
.770659 [NOTICE] [3481905] [36.71.175.65:56180:HTTP2-91#APVH_*****.**:443] [STDERR] The Automattic\WooCommerce\Admin\API\Options::get_options function is deprecated since version 3.1.I think there are problems on my whole Woocommerce REST API.
My call to GET wp-json/wc/v3/products also returning:
{"code":"woocommerce_rest_cannot_view","message":"Sorry, you cannot list resources.","data":{"status":401}}
GET wp-json/wc/v3/products doesn’t need any authorization, am I correct?
Hi there,
GET wp-json/wc/v3/products doesn’t need any authorization, am I correct?
It requires authorization otherwise anyone could retrieve the list of your products. Error code 401 indicates an authorization issue. You can read more about this here:
https://www.ads-software.com/support/topic/get-woocoomerce-api/#post-15723358
I would double-check your HTTP PUT request is entered correctly and would try different authorization methods.
Image Link: https://snipboard.io/oyHMpf.jpghttps://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-product
If the issue persists, I’ll give Rashed’s advice a try and contact the hosting provider as depending on where the site is hosted there could be a firewall on the server blocking API requests due to security settings.
Thanks.
I can confirm that curl command in the above screenshot is working.
And below code should present in .htaccess in my case:
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0 RewriteRule ^wp-json/.* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
But I still have not succeed using Postman and also with consumer key and secret as url variables (https://domain_name/wp-json/wc/v3/products/<<product_id>>/?consumer_key=XXXXXXX&consumer_secret=XXXXXXX
Hello @barotoardi,
Have you reached out to your hosting provider? Any updates on that front?
Hi Paulo,
I already contacted my hosting provider regarding whether they block PUT request, but they don’t block it.Anything more that I should ask about?
How about authorization using url variables? is there any specific setting (maybe in .htaccess) to enable that?
Hello @barotoardi ,
Anything more that I should ask about?
Can you please try to update a regular WordPress post using a PUT request?
You need to use the same method as mentioned here but instead of using POST try using PUT. If PUT requests are supported by your host, you should see the change in the post. If it doesn’t work, then it is a problem with the server configuration and you need to ask your hosting provider to investigate further so that PUT requests are accepted.
You can use the Basic authentication method for the WordPress post-test.
How about authorization using url variables? is there any specific setting (maybe in .htaccess) to enable that?
I am not aware of any specific .htaccess settings for authorization URL. You can also ask this in the WooCommerce FB group, or the
#developers
channel of our Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, too.
- The topic ‘Can’t update product using REST API’ is closed to new replies.