How to Update product using REST API /V1/products/:sku in Magento 2?

In Magento 2, You can update already existing products using REST API. You need to call the updated product request URL to perform the update action.

For Update Product, you need to call the PUT method as action Type.

Action: PUT

Request URL: <YOUR_SITE_URL>/rest/V1/products/<SKU>

Replace YOUR_SITE_URwith the actual site URL and SKU with your product SKU which you want to update data.

For Header, You need to pass,
‘Content-Type:application/json’,’Authorization:Bearer ‘.$accessToken’

Where $accessToken is your site Access Token. You can get $accessToken from Create Access Token Magento 2

<?php
$url= "http://127.0.0.1/magento2ee/index.php/rest";
$accessToken=  "YOUR_ACCESS_TOKEN_STRING";
$setHeaders = array('Content-Type:application/json','Authorization:Bearer '.$accessToken);

$url = $url."/V1/products/my product sku";
$apiUrl = str_replace(" ","%20",$url);

$ch = curl_init();
$data = [
  "product" => [
    "visibility" => 2,
    "price" => 250,
    "custom_attributes" => [
        [
            "attribute_code" => "description",
            "value"=> "test description."
        ]
    ]
  ]
];

$data_string = json_encode($data);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $setHeaders);
$token = curl_exec($ch);

$response = json_decode( curl_exec($ch), TRUE);
curl_close($ch);
echo "<pre>";print_r($response);exit;

Using the above script you can update the product in Magento 2.