And here it is a bit more information. Now I'm adding the full object on the query as per the documentation:
This is how I create the body of my put request:
1. I use the getListingInventory endpoint with the query parameter includes: "Listing". And this is the response:
{"products":[{"product_id":
2145943226,"sku":"CIO-1002","is_deleted":false,"offerings":[{"offering_id":2001427797,"quantity":994,"is_enabled":true,"is_deleted":false,"price":{"amount":66,"divisor":100,"currency_code":"USD"}}],"property_values":[{"property_id":200,"property_name":"Primary color","scale_id":null,"scale_name":null,"value_ids":[1],"values":["Black"]}]}],"price_on_property":[200],"quantity_on_property":[200],"sku_on_property":[200],"listing":{"listing_id":576120207,"user_id":117697394,"shop_id":16552740,"title":"CIO-1002","description":"CIO-1002 test product 1","state":"active","creation_timestamp":1627068991,"ending_timestamp":1637699791,"original_creation_timestamp":1512000711,"last_modified_timestamp":1627068991,"state_timestamp":1527712231,"quantity":994,"shop_section_id":null,"featured_rank":-1,"url":"https:\/\/
www.etsy.com\/listing\/576120207\/cio-1002","num_favorers":0,"non_taxable":false,"is_customizable":false,"listing_type":0,"tags":[],"materials":[],"shipping_profile_id":52997705509,"processing_min":1,"processing_max":3,"who_made":"i_did","when_made":"2010_2019","is_supply":false,"item_weight":null,"item_weight_unit":null,"item_length":null,"item_width":null,"item_height":null,"item_dimensions_unit":null,"is_private":false,"recipient":null,"occasion":null,"style":[],"file_data":"","has_variations":true,"should_auto_renew":false,"language":"en-US","price":{"amount":66,"divisor":100,"currency_code":"USD"},"taxonomy_id":825}}
2. From that response I create the body of my endpoint updateListingInventory:
PUT Request:
https://openapi.etsy.com/v3/application/listings/576120207/inventory; '{"products":[{"sku":"CIO-1002","property_values":[{"property_id":200,"value_ids":[1],"scale_id":0,"property_name":"Primary color","values":["Black"]}],"offerings":[{"price":0.66,"quantity":83,"is_enabled":true}]}],"price_on_property":[200],"quantity_on_property":[200],"sku_on_property":[200]}
3. I use this header:
$header = [
'Content-Type: application/json',
'x-api-key: '.Etsy::$consumer_key,
'Authorization: Bearer '.$this->access_token,
];
But I keep on getting the 400 error with message "cannot load body of that type"
Could anyone advise how to fix this issue?
Also, is it necessary to include the fields "price_on_property":[200],"quantity_on_property":[200],"sku_on_property":[200]? Following the documentation they seem optional, but there's this warning message that I'm not sure what it refers to:
"Updates the inventory for a listing identified by a listing ID. The update fails if the supplied values for product sku, offering quantity, and/or price are incompatible with values in *_on_property_* fields. When setting a price, assign a float equal to amount divided by divisor as specified in the Money resource".
Also, I tried getting the property_id from the endpoint getListingProperties, but that property_id (which was different) didn't seem to work either.
Thank you for your support,