Quantcast
Channel: Opinion: Shopify Community - Shopify APIs & SDKs
Viewing all articles
Browse latest Browse all 25503

Updating images through API by Mike Convey

$
0
0

 

We have been using the API in production for quite some time to update images for products. As of a few days ago however this is no longer working. We send the new image and the API operation completes without any errors, but the existing image is removed from the product and the new image is not added.  For example:

Product as retrieved from the API before we update the image:

                           'shopify' => {
                                           'options' => [
                                                          {
                                                            'product_id' => 396115299,
                                                            'position' => 1,
                                                            'name' => 'Unit',
                                                            'id' => 466927811
                                                          }
                                                        ],
                                           'published_scope' => 'global',
                                           'product_type' => 'Wine',
                                           'created_at' => '2014-10-29T17:36:37+08:00',
                                           'id' => 396115299,
                                           'published_at' => '2014-10-29T17:36:37+08:00',
                                           'images' => [
                                                         {
                                                           'variant_ids' => [],
                                                           'created_at' => '2014-10-30T07:36:34+08:00',
                                                           'product_id' => 396115299,
                                                           'src' => 'https://cdn.shopify.com/s/files/1/0651/8439/products/CPG-LRN-06.png_random_4793.png?v=1414625794';,
                                                           'updated_at' => '2014-10-30T07:36:34+08:00',
                                                           'position' => 2,
                                                           'id' => 919439215
                                                         }
                                                       ],
                                           'tags' => '2000 - 2010, 90+, Birthday and Anniversary Wines, Champagne, France, Other Varieties, Sparkling, Standard, White',
                                           'image' => {
                                                        'variant_ids' => [],
                                                        'created_at' => '2014-10-30T07:36:34+08:00',
                                                        'product_id' => 396115299,
                                                        'src' => 'https://cdn.shopify.com/s/files/1/0651/8439/products/CPG-LRN-06.png_random_4793.png?v=1414625794';,
                                                        'updated_at' => '2014-10-30T07:36:34+08:00',

                                                        'position' => 2,
                                                        'id' => 919439215
                                                      },
                                           'template_suffix' => undef,
                                           'variants' => [
                                                           {
                                                             'option1' => '75cl',
                                                             'sku' => 'CPG-LRN-06',
                                                             'fulfillment_service' => 'manual',
                                                             'position' => 1,
                                                             'compare_at_price' => '700.00',
                                                             'created_at' => '2014-10-29T17:36:37+08:00',
                                                             'product_id' => 396115299,
                                                             'image_id' => undef,
                                                             'old_inventory_quantity' => 0,
                                                             'id' => 932012735,
                                                             'inventory_policy' => 'deny',
                                                             'inventory_management' => 'shopify',
                                                             'grams' => 1500,
                                                             'barcode' => undef,
                                                             'option3' => undef,
                                                             'taxable' => $VAR1->{'BDY-BEAUNE-84'}{'shopify'}{'variants'}[0]{'taxable'},
                                                             'inventory_quantity' => 0,
                                                             'option2' => undef,
                                                             'updated_at' => '2014-10-29T17:36:37+08:00',
                                                             'title' => '75cl',
                                                             'price' => '700.00',
                                                             'requires_shipping' => $VAR1->{'BDY-BEAUNE-84'}{'shopify'}{'variants'}[0]{'taxable'}
                                                           }
                                                         ],

                                           'handle' => '2006-louis-roederer-brut-nature-in-gift-box',
                                           'updated_at' => '2014-10-30T07:36:34+08:00',
                                           'body_html' => '0',
                                           'title' => '2006 Louis Roederer Brut Nature in Gift Box',
                                           'vendor' => 'Abbelio Wines'

Our update:

{"product":{"variants":[{"inventory_management":"shopify","sku":"CPG-LRN-06","id":932012735,"inventory_policy":"deny"}],"images":[{"src":"https://www.abbelio-wines.com.hk/_img//medium/CPG-LRN-06.png?random=5600.46958594711"}],"body_html":"The new collaboration between Louis Roederer and Philipe Stark!"}}

Return from API:

         'product' => {
                         'images' => [],
                         'published_at' => '2014-10-29T17:36:37+08:00',
                         'options' => [
                                        {
                                          'product_id' => 396115299,
                                          'position' => 1,
                                          'name' => 'Unit',
                                          'id' => 466927811
                                        }
                                      ],
                         'tags' => '2000 - 2010, 90+, Birthday and Anniversary Wines, Champagne, France, Other Varieties, Sparkling, Standard, White',
                         'published_scope' => 'global',
                         'variants' => [
                                         {
                                           'option1' => '75cl',
                                           'sku' => 'CPG-LRN-06',
                                           'fulfillment_service' => 'manual',
                                           'position' => 1,
                                           'compare_at_price' => '700.00',
                                           'created_at' => '2014-10-29T17:36:37+08:00',
                                           'product_id' => 396115299,
                                           'image_id' => undef,
                                           'old_inventory_quantity' => 0,
                                           'id' => 932012735,
                                           'inventory_policy' => 'deny',
                                           'inventory_management' => 'shopify',
                                           'grams' => 1500,
                                           'barcode' => undef,
                                           'option3' => undef,

                                         'taxable' => bless( do{\(my $o = 1)}, 'JSON::XS::Boolean' ),
                                           'inventory_quantity' => 0,
                                           'option2' => undef,
                                           'updated_at' => '2014-10-29T17:36:37+08:00',
                                           'title' => '75cl',
                                           'price' => '700.00',
                                           'requires_shipping' => $VAR1->{'product'}{'variants'}[0]{'taxable'}
                                         }
                                       ],
                         'product_type' => 'Wine',
                         'template_suffix' => undef,
                         'created_at' => '2014-10-29T17:36:37+08:00',
                         'handle' => '2006-louis-roederer-brut-nature-in-gift-box',
                         'updated_at' => '2014-11-03T13:54:19+08:00',
                         'title' => '2006 Louis Roederer Brut Nature in Gift Box',
                         'body_html' => 'The new collaboration between Louis Roederer and Philipe Stark!',
                         'id' => 396115299,
                         'vendor' => 'Abbelio Wines'
                       }

The product has been successfully updated but the image has not (and the original image has been removed).

We haven't changed anything on our side, so it seems something has changed in the API?  Please could you advise if this is the case and if so whether there's a change we need to make on our side as a result?

Thanks and regards

Mike

 

 

 


Viewing all articles
Browse latest Browse all 25503

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>