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

Shane Parkinson commented on How to set the default product variant through API?

$
0
0

Hello,

I still can't figure this out, if you can't set the default variant then there is no way to set the SKU or even the price when adding products via the API !

API docs show this to create a default variant product.  Which will create a default variant with no SKU or price...

{  
   "product":{  
      "title":"Burton Custom Freestlye 151",
      "body_html":"<strong>Good snowboard!</strong>",
      "vendor":"Burton",
      "product_type":"Snowboard",
      "images":[  
         {  
            "src":"http://example.com/rails_logo.gif&quot;
         }
      ]
   }
}

The following returns a (422) Unprocessable Entity, the JSON works for creating variants which aren't "default" but is not happy with what is shown below.

NOTE: I have tried with the "options" tag and "name" : "title" but it fails also.

{  
   "product":{  
      "body_html":"Every element of IntelliMouse Pro - from its unique arched shape to the texture of the rubber grip around its base - is the product of extensive customer and ergonomic research. Microsoft's popular wheel control, which now allows zooming and universal scrolling functions, gives IntelliMouse Pro outstanding comfort and efficiency.",
      "created_at":"2014-04-28T11:19:43",
      "published_at":"2014-04-28T11:19:43",
      "product_type":"Mice",
      "title":"Microsoft IntelliMouse Pro",
      "vendor":"Warner",
      "published":true,
      "sku":"MSIMPRO",
      "variants":[  
         {  
            "option1":"Default",
            "option2":null,
            "option3":null,
            "sku":"MSIMPRO",
            "barcode":null,
            "price":"49.99",
            "compare_at_price":null,
            "position":1,
            "inventory_management":"shopify",
            "inventory_policy":"deny",
            "fulfillment_service":"manual",
            "requires_shipping":true,
            "taxable":false,
            "inventory_quantity":null,
            "created_at":null,
            "grams":null
         }
      ]
   }
}

Regards

Shane :)


Viewing all articles
Browse latest Browse all 25503


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