Image URL related error creating category via REST API
-
Hi,
I am having a problem trying to use the API to create a Product Category with an image.
I am using the Ruby gem but I have the same problem using a standard call via Postman.This is what I am sending in the request, if I send it without image it works fine but with an image I get “woocommerce_api_product_category_image_upload_error – Error getting remote image”
{ "product_category": { "name": "Categoria uma2", "slug": "Categoriauma2", "description": "nil", "image": { "src": "https://same_server_as_wordpress.com/wp-content/uploads/2020/09/2a.jpg" } } }
It is a test server and no other plugins are installed, the image is accessible in the WP server.
I debugged WP and it is not a connection problem, as the URL is never really used, this is the error:
ltrim() expects parameter 1 to be string, array given in /var/www/html/wp-includes/formatting.php on line 4313This corresponds to the function esc_url that receives the URL and escapes it, the function expects the URL to be a string but it is receiving an array instead.
I examined the array and it is part of the request:
a:1:{s:3:”src”;s:71:”https://wordpress.stable.wrightia.com/wp-content/uploads/2020/09/2a.jpg”;}Backtracing the call of the esc_url function, I see it is called by WP_Scripts, but when I get to this point there is nothing I can do on my side to solve this, as I do not want to edit WP or WC files.
What am I missing here? The request is correct and according to the documentation and I have both WP and WC updated (please remind that without image the creation works).
I am driving nuts as I am looking for a solution for days, can someone please shed a light on this.
### WordPress Environment ### WordPress address (URL): https://my_server.com Site address (URL): https://my_server.com WC Version: 4.5.2 REST API Version: ? 4.5.2 WC Blocks Version: ? 3.1.0 Action Scheduler Version: ? 3.1.6 WC Admin Version: ? 1.5.0 Log Directory Writable: ? WP Version: 5.5.1 WP Multisite: – WP Memory Limit: 1,000 MB WP Debug Mode: ? WP Cron: ? Language: pt_PT External object cache: – ### Server Environment ### Server Info: Apache/2.4.38 (Debian) PHP Version: 7.3.18 PHP Post Max Size: 300 MB PHP Time Limit: 600 PHP Max Input Vars: 1000 cURL Version: 7.64.0 OpenSSL/1.1.1d SUHOSIN Installed: – MySQL Version: 8.0.21 Max Upload Size: 300 MB Default Timezone is UTC: ? fsockopen/cURL: ? SoapClient: ? Your server does not have the SoapClient class enabled - some gateway plugins which use SOAP may not work as expected. DOMDocument: ? GZip: ? Multibyte String: ? Remote Post: ? Remote Get: ? ### Database ### WC Database Version: 4.5.2 WC Database Prefix: wp_ Total Database Size: 3.31MB Database Data Size: 1.94MB Database Index Size: 1.37MB wp_woocommerce_sessions: Data: 0.09MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_actions: Data: 0.02MB + Index: 0.11MB + Engine InnoDB wp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_logs: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_comments: Data: 0.02MB + Index: 0.08MB + Engine InnoDB wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_options: Data: 1.03MB + Index: 0.03MB + Engine InnoDB wp_postmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_posts: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_admin_notes: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB ### Post Type Counts ### attachment: 2 page: 6 post: 2 ### Security ### Secure connection (HTTPS): ? Hide errors from visitors: ? ### Active Plugins (1) ### WooCommerce: by Automattic – 4.5.2 ### Inactive Plugins (2) ### Akismet Anti-Spam: by Automattic – 4.1.6 Hello Dolly: by Matt Mullenweg – 1.7.2 ### Settings ### API Enabled: ? Force SSL: – Currency: EUR (€) Currency Position: left Thousand Separator: . Decimal Separator: , Number of Decimals: 2 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: – ### WC Pages ### Shop base: #6 - /loja/ Cart: #7 - /carrinho/ Checkout: #8 - /finalizar-compra/ My account: #9 - /minha-conta/ Terms and conditions: ? Page not set ### Theme ### Name: Twenty Twenty Version: 1.2 (update to version 1.5 is available) Author URL: https://www.ads-software.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: 1 Oldest: 2020-09-23 15:49:54 +0000 Newest: 2020-09-23 15:49:54 +0000
- The topic ‘Image URL related error creating category via REST API’ is closed to new replies.