I am using PHP and trying update an Etsy listing that has variations. My code is as follows:
$this->my_etsy->getAccessToken(site_url('inventory/etsy/update_price'));
$api_url = 'https://openapi.etsy.com/v2/listings/<my_listing_id>/inventory';
$listing_data = array(
'listing_id' => <my_listing_id>
);
$success = $this->my_etsy->client->CallAPI($api_url, 'GET', $listing_data, array('FailOnAccessError'=>true), $response);
//print_r($response);
$new_data = json_decode(json_encode($response->results), true);
$sub_data = [];
foreach($new_data['products'] as $key=>$val){
foreach($new_data['products'][$key]['offerings'] as $k=>$v){
$price = ceil($new_data['products'][$key]['offerings'][$k]['price']['amount']*.8);
$sub_data['products'][$key]['offerings'][$k]['price']['amount'] = $price;
}
}
//print_r($sub_data);
$arr = array(
'products' => json_encode($sub_data),
'price_on_property' => 513,
'quantity_on_property' => '',
'sku_on_property' => ''
);
$api_url = 'https://openapi.etsy.com/v2/listings/<my_listing_id>/inventory';
$success = $this->my_etsy->client->CallAPI($api_url, 'PUT', $sub_data, array('FailOnAccessError'=>true), $response);
print_r($response);
I've tried a bunch of different ways to pass the data and nothing works. The error that I am currently getting is:
[Server_Error] =>
Any ideas as to what I'm doing wrong?