For some reason, you have to double the arrays, maybe this doesn’t affect you as you are referencing the firt element. I use this in PHP:
function saveMetaItem($id_order,$id_item,$id_product,$meta_key,$meta_value){
$woo = new wooclient();
$data = array(
'line_items' => array(array(
'id' => $id_item,
'product_id' => $id_product,
'meta_data' => array(array(
'key' => $meta_key,
'value' => $meta_value
))
))
);
$result = $woo->put('orders/'.$id_order, $data);
return $result;
}
Notice the double array() calls in both line_items and meta_data. Also provide both id
and product_id
. Convert that to JSON and your done 😉