What are the common HTTP methods used in REST API for creating and updating data?

The common HTTP methods used in REST API for creating and updating data are POST and PUT/PATCH.

// Creating data using POST method
$ch = curl_init('http://api.example.com/data');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['name' => 'John Doe', 'age' => 30]));
$response = curl_exec($ch);
curl_close($ch);

// Updating data using PUT method
$ch = curl_init('http://api.example.com/data/1');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['name' => 'Jane Smith', 'age' => 35]));
$response = curl_exec($ch);
curl_close($ch);