Search code examples
apietsy

Getting Error when trying to add new variations with Etsy API V3


I'm getting the error: "Expected int value for 'property_id' (got NULL)" when trying to add new variations to my Listing, using the EndPoint updateListingInventory.

Note: I get the message error only when trying to add a new variations to a listing, when I'm editing existing variations the endpoint updateListingInventory works without any problèm.

here is an example of data I send:

array:2 [
"products" => array:21 [
     0 => array:3 [
            "sku" => "2020"
            "property_values" => array:4 [
                                 "property_id" => 513
                                 "value_ids" => array:1 [
                                                 0 => 1
                                                 ]
                                 "property_name" => "Size"
                                 "values" => array:1 [
                                             0 => "4x6ft/120x180cm"
                                             ]
                                  ]
            "offerings" => array:3 [
                              "price" => 858.0
                              "quantity" => 100
                              "is_enabled" => true
                              ]
          ]
]
"price_on_property" => array:1 []

Although I send the property_id as you notice (513 for custom property), I get the error "Expected int value for 'property_id' (got NULL)".

Can you please tell me what's wrong?

If you need any further pieces of information I'll be happy to share them with you.

Best Regards.


Solution

  • My bad, offrenigs and property_values should be an array of OBJECTS. for example

    "offerings" => array:1 [
            0 => array:3 [
              "price" => 858.0
              "quantity" => 100
              "is_enabled" => true
            ]
          ]
    

    Best Regards