Discussions

Ask a Question
Back to all

PHP code to update inventory

Hi

Can anyone guide is it the correct php code to update inventory by SKU id ?


$json = '{
sku: "****",
availableInventory: "40"
}';

$headers = array(
'Content-Type:application/json',
'X-Auth-Token: *',
'X-Seller-Authz-Token: **',
'ClientId: Company Name '
);

$url  = "http://staging-apigateway.snapdeal.com/seller-api/products/inventory";	
$curl = curl_init(); 

curl_setopt($curl, CURLOPT_URL,$url);

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);	
$result = curl_exec($curl);
curl_close($curl);
print_r($result);