I am trying to update user roles using restws module. Please refer to the code given below:
$url = "http://DRUPAL_ROOT/user/3";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "restws_test1" . ":" . "password");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
$data = array("roles" => array("3" => 3));
//I've tried following as alternatives:
//$data = array("roles" => array("3" => "3"));
//$data = array("roles" => array(3 => "3"));
//$data = array("roles" => array(3 => 3));
$data_string = json_encode($data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array (
"Content-Type: application/json",
"Content-Length: ".strlen($data_string)
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$retValue = curl_exec($ch);
var_dump($retValue);
curl_close($ch);
This code gives me following error: