Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

inventory update via api

inventory update via api

chetangupta395
Visitor
1 0 0

I am adjusting and  set quantity using the API but its show response below.

[inventory_item_id] => Required parameter missing or invalid

 I am showing code below.

 

$url = 'https://' . $API_KEY . ':' . $PASSWORD . '@' . $STORE_URL . '/admin/api/2022-04/inventory_levels/adjust.json';
//$url = "https://amswan01.myshopify.com/admin/api/2022-06/inventory_levels/set.json";
$updatePrdInfo = array(
'product' => array(
'location_id' => 66712895646,
'inventory_item_id' => 43497078620318,
'available_adjustment' => 221
)
);
$data_json = json_encode($updatePrdInfo);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($data_json)));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result_json = curl_exec($ch);
$result = json_decode($result_json,true);
echo "<pre>";
print_r($result);

 

And response 

 

Array
(
    [errors] => Array
        (
            [inventory_item_id] => Required parameter missing or invalid
        )

)
Replies 0 (0)