500 on create product POST

Im sure it is something I am missing in the request but cannot seem to spot it a little help please. Even tried stripping down to minimum required vars

request sent:

{  
   "product":{  
      "title":"test product",
      "product_variants_attributes":[  
         {  
            "title":"test112",
            "sku_code":"test112",
            "price":"0.01",
            "tax_rate":"0.2",
            "weight_grams":"0"
         }
      ],
      "images_attributes":{  
         "src":"https://dirtbusters.co.uk/images/products/test-product-20180305130341.png",
         "display_position":1
      }
   }
}

Hey,

This JSON just worked for me to create a product:

{
  "product": {
    "title": "Bobble Hat -  Title",
    "product_variants_attributes": [
      {
        "title": "One Size - ProdVariantTitle",
        "sku_code": "b-hat-1",
        "price": "10"
      }
    ]
  }
}

Just change your images_attributes

{  
   "product":{  
      "title":"test product",
      "product_variants_attributes":[  
         {  
            "title":"test112",
            "sku_code":"test112",
            "price":"0.01",
            "tax_rate":"0.2",
            "weight_grams":"0"
         }
      ],
      "images_attributes":[
            {  
              "src":"https://dirtbusters.co.uk/images/products/test-product-20180305130341.png",
              "display_position":1
            }
    ],
   }
}

It will surely work. Check documentation

1 Like